-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.txt
107 lines (81 loc) · 3.49 KB
/
design.txt
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Game.java:
Game is our main class. It extends JPanel and implements JavaArcade. It has
many jobs, which can be split into the following categories. These categories
can be actual classes or namespaces in the code, or they can simply be sections
of code divided up using comments. For the sake of this document, I will refer
to them as if they are proper namespaces.
Input:
- JavaArcade interface
- Keyboard
Output:
- JavaArcade interface
- Visual (via the methods we inherited via JPanel).
- Audio
Processing:
- Ticker
- GameLogic
- AssetManager
Input
Input.JavaArcade's job is to properly implement the methods from JavaArcade
that correspond to user input, and inform Processing.GameLogic that those
messeges were recived.
Input.Keyboard's job is to take keyboard input.
Bind:
key
pressedSignal - sent once when the key is first pushed down
downSignal - sent continuously while the key is down
press()
release()
getSignal()
Input.Keyboard:
addBind(bind)
getSignals() - for every bind that has been added, return the signals that
it's sending.
Output
Output.JavaArcade's job is to properly implement the methods from JavaArcade
that return data.
Output.Visual's job is to draw the RenderInfos from Processing.GameLogic.
RenderInfo (abstract):
double x, y (location of the bottom left corner of sprite, using
Processing.GameLogic's coordinate system)
sprite
SwingRendeInfo is the implementation of RenderInfo that we'll be using.
Output.Visual:
draw(renderInfos):
for renderInfo in renderInfos:
convert coordinates to JPanel's coordinate system
draw the sprite
Output.Audio's job is to play any audio that Game.GameLogic is sending.
Output.Audio
play(Object toPlay)
Processing
Processing.Ticker's job is to periodically check for input form Input.Keyboard,
forward Input's signals to Processing.GameLogic, and forward
Processing.GameLogic's RenderInfos and AudioInfos to Output.Visual and
Output.Audio respectively.
Processing.GameLogic's job is to keep track of the state of all entities, to
update their state based on the user's inputs (sent to it from Input via
Processing.Ticker) and the passage of time (as reported by Processing.Ticker),
and to send all of the RenderInfos that Renderables produce back to Game to be
drawn. GameLogic will use doubles to represent coordinates, and will have its
origin in the lower left corner (i.e., increasing x moves right, and increasing
y moves up).
Processing.AssetManager allows entites to request that sprites, and audio files
be loaded. It will be constructed in Game, and be passed to all Renderables.
Processing.AssetManager:
Image loadSprite()
Audio loadAudio()
Tests:
TestUI provides a testing environment for classes which implement JavaArcade.
NullGame is a simple example JavaArcade game which does nothing.
Math:
Vector2 is a class which represents a 2D vector. It will be used for physics
calculations.
Shape is a generic super class for collision detection
Shape:
isTouching(shape other) - returns weahter or not this's area/perimeter
share one or more points with other's
area/perimeter.
Not all shapes will necessarily be able to test for collisions with each other.
If collision detection isn't implemented for a specific Shape, then an
exception will be thrown.