-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Host.inl
64 lines (44 loc) · 1.59 KB
/
Host.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* Interactive Gym Environment and Educational Kit (iGeek) @version 0.x
@link https://github.com/KabukiStarship/iGeek.git
@file /host.inl
@author Cale McCollough <https://cookingwithcale.org>
@license Copyright (C) 2015-2023 Kabuki Starship <kabukistarship.com>;
All right reserved (R). This Source Code Form is subject to the terms of the
Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
this file, You can obtain one at <https://mozilla.org/MPL/2.0/>. */
#include <_Config.h>
#include "host.h"
namespace _ {
Host::Host(ISC width, ISC height, ISC numberOfCells, ISC numberOfViruses) {
setPreferredSize(new Dimension(width, height));
setBorder(BorderFactory.createLineBorder(Color.BLACK));
cells = new Cell[numberOfCells];
numCells = numberOfCells;
for (ISC i = 0; i < numberOfCells; i++) cells[i] = new Cell(this);
viruses = new VirusPopulation(this);
hostColor = DefaultHostColor;
backgroundColor = DefaultBackgroundColor;
}
ISC Host::getNumCells() { return numCells; }
VirusPopulation Host::virusPopulation() { return viruses; }
void Host::Update() {
viruses.Update();
// Check to see if a Virus occupies a cell.
for (ISC i = 0; i < numCells; i++) {
Cell currentCell = cells[i];
if (viruses.contains(currentCell) >= 0) {
// if (currentCell.getMass ())
// ;
}
}
}
void Host::paintComponent(Graphics g) {
super.paintComponent(g);
setBackground(backgroundColor);
Dimension bounds = getPreferredSize();
g.setColor(hostColor);
g.fillRect(0, 0, bounds.width, bounds.height);
viruses.draw(g);
}
} //< namespace _
}