-
Notifications
You must be signed in to change notification settings - Fork 1
/
spacewar.htm
191 lines (180 loc) · 5.83 KB
/
spacewar.htm
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="content-security-policy" content="
base-uri 'self';
default-src 'none';
child-src blob:;
frame-src blob:;
connect-src https://api.stackexchange.com;
script-src 'self' 'unsafe-inline' blob:;
worker-src blob:;
style-src 'self';
img-src 'self';
form-action 'none';
">
<!-- these properties are read by the engine to configure the game -->
<title>Spacewar!</title>
<link rel="icon" href="favicons/spacewar.png">
<meta name="stack-exchange-site" content="codegolf">
<meta name="stack-exchange-qid" content="67560">
<meta name="team-view-columns" content='[]'>
<meta name="team-type" content="free_for_all">
<meta name="team-type-args" content='{}'>
<meta name="tournament-type" content="all_v_all">
<meta name="tournament-type-args" content='{
"teamLimit": 2
}'>
<meta name="match-type" content="brawl">
<meta name="match-type-args" content='{
"count": 20,
"teamShuffle": "roundRobin"
}'>
<meta name="game-type" content="spacewar">
<meta name="game-config" content='{
"width": 800,
"height": 600,
"sun": {"x": 400, "y": 300, "radius": 5, "G": 5000},
"startInsetX": 50,
"startInsetY": 50,
"turnSpeeds": {
"all": 0.087266462599716,
"wing": 0.043633231299858,
"nose": 0
},
"initialMissiles": 20,
"missileSpeed": 10,
"missileCooldownFrames": 4,
"missileLifetime": 75,
"acceleration": {
"all": 0.3,
"wing": 0.15,
"nose": 0
},
"maxEngineSpeed": 15,
"maxSpeed": 40,
"maxMissileSpeed": 56.56,
"missileSpawnDistance": 10,
"deathFrames": 34,
"resetFrames": 100,
"hyperspaceFrames": 34,
"hyperspaceFatalityRatio": {
"all": 0.25,
"wing": 0.5,
"nose": 0.5
},
"shapes": {
"all": [[-8, 16], [0, -8], [8, 16]],
"noseLeftWing": [[-8, 16], [0, -8], [4, 4], [0, 8], [0, 16]],
"noseRightWing": [[-4, 4], [0, -8], [8, 16], [0, 16], [0, 8]],
"leftWing": [[-8, 16], [-4, 4], [0, 8], [0, 16]],
"rightWing": [[4, 4], [8, 16], [0, 16], [0, 8]],
"nose": [[-4, 4], [0, -8], [4, 4], [0, 8]]
},
"shipMaxRadius": 20,
"maxFrame": 3000
}'>
<meta name="play-config" content='{
"delay": 0,
"speed": 1
}'>
<meta name="play-screensaver-config" content='{
"delay": 30,
"speed": 1,
"swapDelay": 5000
}'>
<meta name="display-config" content='{
"scale": 1,
"view3D": false,
"shapes": {
"leftWing": [[-8, 16], [-4, 4], [0, 8], [0, 16]],
"rightWing": [[4, 4], [8, 16], [0, 16], [0, 8]],
"nose": [[-4, 4], [0, -8], [4, 4], [0, 8]],
"flame": [
[[-4, 16], [0, 20], [4, 16]],
[[-4, 16], [0, 24], [4, 16]]
],
"leftFlame": [
[[-4, 16], [0, 20], [0, 16]],
[[-4, 16], [0, 24], [0, 16]]
],
"rightFlame": [
[[0, 16], [0, 20], [4, 16]],
[[0, 16], [0, 24], [4, 16]]
]
},
"colourscheme": "space"
}'>
<meta name="default-code" content="/*
* BotName_setup is called at the start of each game
*
* Input:
* team - 'red' (start left) or 'blue' (start right)
*
* Return: an object to pass to later Bot_getActions calls
*/
function Bot_setup(team) {
return {};
}
/*
* BotName_getActions is called each frame
*
* Input:
* gameInfo - an object containing the current game state
* timeLeft - time left in game (seconds)
* fieldWidth - width of board
* fieldHeight - height of board
* sun_x / sun_y / sun_r - location and kill-radius of sun
* gravityStrength - acceleration due to gravity of sun at 1 pixel away
* engineThrust - acceleration provided by engines when ship is
* undamaged (pixels/frame^2)
* speedLimit - maximum speed (pixels/frame) attainable on engine
* power
* maxSpeed - maximum speed (pixels/frame) attainable by any
* means
* numMissiles - the number of missiles currently flying
* missiles - an array of objects (x, y, xv, yv) denoting the
* current state of all flying missiles
* redScore / blueScore - score of player
* red_x / red_y / blue_* - location of player
* red_rot / blue_rot - rotation of player in degrees (0 = up, 90 = right)
* red_xv / red_yv / blue_* - velocity of player
* red_shape / blue_shape - name of shape for player ('full ship' /
* 'left wing' / 'right wing' / 'nose only') -
* matches shipShapes global
* red_missileStock / blue_* - number of missiles remaining for player
* red_inHyperspace / blue_* - true if the player is currently in hyperspace
* (intangible)
* red_exploded / blue_* - true if the player has exploded after dying
* (intangible)
* red_alive / blue_alive - true if the player is still alive. If false and
* *_exploded is also false, the player is currently
* 'frozen' and hazardous to touch
* botVars - the object returned by Bot_setup (mutable)
*
* Globals:
* shipShapes - an object containing vector shapes for ships in various
* states: 'full ship', 'left wing', 'right wing', 'nose'
* LineIntersection - a function which computes the intersection point of two
* line segments
* getShipCoords - a function which returns the current shape of a ship
* ('red' or 'blue') rotated and positioned on the board
*
* Return: a list of actions:
* 'turn left' - turn 5 degrees counter-clockwise
* 'turn right' - turn 5 degress clockwise
* 'fire engine' - accelerate forwards
* 'fire missile' - fire a missile (no-op if no missiles left or too rapid)
* 'hyperspace' - enter hyperspace
*/
function Bot_getActions(gameInfo, botVars) {
return [];
}
">
<script src="core/requirejs.js"></script>
<script src="engine/entry.js" async></script>
</head>
<body>
<noscript>This viewer requires Javascript!</noscript>
</body>
</html>