Skip to content

Commit 226d610

Browse files
committed
resolved component issue
1 parent 92db9db commit 226d610

File tree

12 files changed

+0
-619
lines changed

12 files changed

+0
-619
lines changed

component/src/main/java/com/iluwatar/component/App.java

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1 @@
1-
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3-
*
4-
* The MIT License
5-
* Copyright © 2014-2022 Ilkka Seppälä
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
13-
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
16-
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
package com.iluwatar.component;
261

27-
import com.iluwatar.component.component.graphiccomponent.GraphicComponent;
28-
import com.iluwatar.component.component.graphiccomponent.ObjectGraphicComponent;
29-
import com.iluwatar.component.component.inputcomponent.DemoInputComponent;
30-
import com.iluwatar.component.component.inputcomponent.InputComponent;
31-
import com.iluwatar.component.component.inputcomponent.PlayerInputComponent;
32-
import com.iluwatar.component.component.physiccomponent.ObjectPhysicComponent;
33-
import com.iluwatar.component.component.physiccomponent.PhysicComponent;
34-
import lombok.Getter;
35-
import lombok.RequiredArgsConstructor;
36-
37-
/**
38-
* The GameObject class has three component class instances that allow
39-
* the creation of different game objects based on the game design requirements.
40-
*/
41-
@Getter
42-
@RequiredArgsConstructor
43-
public class GameObject {
44-
private final InputComponent inputComponent;
45-
private final PhysicComponent physicComponent;
46-
private final GraphicComponent graphicComponent;
47-
48-
private final String name;
49-
private int velocity = 0;
50-
private int coordinate = 0;
51-
52-
/**
53-
* Creates a player game object.
54-
*
55-
* @return player object
56-
*/
57-
public static GameObject createPlayer() {
58-
return new GameObject(new PlayerInputComponent(),
59-
new ObjectPhysicComponent(),
60-
new ObjectGraphicComponent(),
61-
"player");
62-
}
63-
64-
65-
/**
66-
* Creates a NPC game object.
67-
*
68-
* @return npc object
69-
*/
70-
public static GameObject createNpc() {
71-
return new GameObject(
72-
new DemoInputComponent(),
73-
new ObjectPhysicComponent(),
74-
new ObjectGraphicComponent(),
75-
"npc");
76-
}
77-
78-
/**
79-
* Updates the three components of the NPC object used in the demo in App.java
80-
* note that this is simply a duplicate of update() without the key event for
81-
* demonstration purposes.
82-
*
83-
* <p>This method is usually used in games if the player becomes inactive.
84-
*/
85-
public void demoUpdate() {
86-
inputComponent.update(this, 0);
87-
physicComponent.update(this);
88-
graphicComponent.update(this);
89-
}
90-
91-
/**
92-
* Updates the three components for objects based on key events.
93-
*
94-
* @param e key event from the player.
95-
*/
96-
public void update(int e) {
97-
inputComponent.update(this, e);
98-
physicComponent.update(this);
99-
graphicComponent.update(this);
100-
}
101-
102-
/**
103-
* Update the velocity based on the acceleration of the GameObject.
104-
*
105-
* @param acceleration the acceleration of the GameObject
106-
*/
107-
public void updateVelocity(int acceleration) {
108-
this.velocity += acceleration;
109-
}
110-
111-
112-
/**
113-
* Set the c based on the current velocity.
114-
*/
115-
public void updateCoordinate() {
116-
this.coordinate += this.velocity;
117-
}
118-
}

component/src/main/java/com/iluwatar/component/component/TaskManager.java

Whitespace-only changes.
Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1 @@
1-
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3-
*
4-
* The MIT License
5-
* Copyright © 2014-2022 Ilkka Seppälä
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
13-
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
16-
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
package com.iluwatar.component.component.graphiccomponent;
261

27-
import com.iluwatar.component.GameObject;
28-
29-
/**
30-
* Generic GraphicComponent interface.
31-
*/
32-
public interface GraphicComponent {
33-
void update(GameObject gameObject);
34-
}
Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +0,0 @@
1-
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3-
*
4-
* The MIT License
5-
* Copyright © 2014-2022 Ilkka Seppälä
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
13-
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
16-
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
package com.iluwatar.component.component.graphiccomponent;
26-
27-
import com.iluwatar.component.GameObject;
28-
import lombok.extern.slf4j.Slf4j;
29-
30-
/**
31-
* ObjectGraphicComponent class mimics the graphic component of the Game Object.
32-
*/
33-
@Slf4j
34-
public class ObjectGraphicComponent implements GraphicComponent {
35-
36-
/**
37-
* The method updates the graphics based on the velocity of gameObject.
38-
*
39-
* @param gameObject the gameObject instance
40-
*/
41-
@Override
42-
public void update(GameObject gameObject) {
43-
LOGGER.info(gameObject.getName() + "'s current velocity: " + gameObject.getVelocity());
44-
}
45-
}
Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +0,0 @@
1-
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3-
*
4-
* The MIT License
5-
* Copyright © 2014-2022 Ilkka Seppälä
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
13-
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
16-
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
package com.iluwatar.component.component.inputcomponent;
26-
27-
import com.iluwatar.component.GameObject;
28-
import lombok.extern.slf4j.Slf4j;
29-
30-
/**
31-
* Take this component class to control player or the NPC for demo mode.
32-
* and implemented the InputComponent interface.
33-
*
34-
* <p>Essentially, the demo mode is utilised during a game if the user become inactive.
35-
* Please see: http://gameprogrammingpatterns.com/component.html
36-
*/
37-
@Slf4j
38-
public class DemoInputComponent implements InputComponent {
39-
private static final int WALK_ACCELERATION = 2;
40-
41-
/**
42-
* Redundant method in the demo mode.
43-
*
44-
* @param gameObject the gameObject instance
45-
* @param e key event instance
46-
*/
47-
@Override
48-
public void update(GameObject gameObject, int e) {
49-
gameObject.updateVelocity(WALK_ACCELERATION);
50-
LOGGER.info(gameObject.getName() + " has moved right.");
51-
}
52-
}
Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1 @@
1-
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
3-
*
4-
* The MIT License
5-
* Copyright © 2014-2022 Ilkka Seppälä
6-
*
7-
* Permission is hereby granted, free of charge, to any person obtaining a copy
8-
* of this software and associated documentation files (the "Software"), to deal
9-
* in the Software without restriction, including without limitation the rights
10-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the Software is
12-
* furnished to do so, subject to the following conditions:
13-
*
14-
* The above copyright notice and this permission notice shall be included in
15-
* all copies or substantial portions of the Software.
16-
*
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23-
* THE SOFTWARE.
24-
*/
25-
package com.iluwatar.component.component.inputcomponent;
261

27-
import com.iluwatar.component.GameObject;
28-
29-
/**
30-
* Generic InputComponent interface.
31-
*/
32-
public interface InputComponent {
33-
void update(GameObject gameObject, int e);
34-
}

0 commit comments

Comments
 (0)