You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>From this object we can get following information:</p>
190
+
<ol>
191
+
<li>
192
+
player - containing information about bot's position, for some games, like in passengerPickup game, it can contain some additional information, like 'path', to determine is path already calculated for this car or it nned to be calculated(you, of course can calculate path each iteration, but it will consume addittional resources) and 'passenger' to find if car is already loaded with passenger or is empty and need to get some
193
+
</li>
194
+
<li>
195
+
collectives - is an array containing objects, each object containing information about position and some additional information if needed (like health and state parameter for plants). Depending on game collectives can be called differently, for example in passengerPickup game it can be called passengers
196
+
</li>
197
+
<li>
198
+
direction - is information about direction bot is moving now, there are two formats: {left:true}, "left"
199
+
</li>
200
+
<li>
201
+
index - is number of character can be 0 or 1 for 1st and 2nd character accordingly
202
+
</li>
203
+
<li>
204
+
config - is game's config.json you can find it in game's root folder ./simulation folder, it will help you to find width, height of collectives and player etc.
205
+
</li>
206
+
<li>
207
+
gameId identifies which game is bot controlled for, left screen has 0 gameId, right - 1.
208
+
</li>
209
+
<li>
210
+
control info is used if you want to control bot with keys it contain of 1st array "keyPressed" that has two elements: first is for left screen controlled bot, second is for right screen, and second array that also, consists of two elements, each element can be 0 or 1, depending on which bot out of two is controllde now, since there can be two bots on each screen. This parameter is changing when user clicks switch button. Left, right, up, down and switch keys names can be found and changed in config.json file for each game
211
+
</li>
212
+
</ol>
213
+
214
+
<h1align="center">Explanation of how to change graphic if needed</h1>
215
+
<h2align="center">What sprite should look like</h2>
216
+
<p>
217
+
Sprite shape should be following:<br> from top to bottom (vertically) there is a state (left, right, up,down moving, running, idle, etc.)<br>
218
+
From left to right (horizontally) should be frames for those states<br>
<h2align="center">Steps to insert new sprite into game</h2>
225
+
<ol>
226
+
<li>
227
+
Save sprite to ./src/assets/sprites folder in the root of chosen game
228
+
</li>
229
+
<li>
230
+
In ./view/Components/Characters/ copy any of files present there and rename it to name like, for example<br>
231
+
import img from '../../../assets/sprites/gnome1.png';<br>
232
+
would be changed to:<br>
233
+
import img from '../../../assets/sprites/your_custom_name.png';<br>
234
+
this file should be already present in assets folder
235
+
</li>
236
+
<li>
237
+
In getAnimationState() switch case should be changed to yours, here are direction present and which direction which state is correspondant to(remember - state is horisontal line of frames, for ex. if up movement is 3rd horisontal line, then<br>
238
+
case 'up': this.animState = 2;)
239
+
</li>
240
+
<li>
241
+
In render you can see Sprite componenet, most important parameters are:<br>
242
+
tileWidth, tileHeight, those indicating original size of each frame, in scale parameter you can see this.props.scale, it's used there to adapt size of sprite depending on scale of the game window in the browser.<br>
243
+
Last important parameter is steps, elements in array are coresponding to the states(horizontal lines) in the sprite. For example, in gnome sprite that was given as an example, 1st horizontal line consists of 8 elements, as well as 2nd, 3rd and 4th, 5th and 6th lines or states consists from 1 frame, so steps parameter would look like [7, 7, 7, 7, 0, 0], since counting starts from 0.
244
+
</li>
245
+
<li>
246
+
In './src/view/character.js' you need to import your sprite here and add new case for your custom sprite
247
+
</li>
248
+
<li>
249
+
In './src/view/App.js' just need to replace type of any Character component to the one you've added to cases
250
+
</li>
251
+
</ol>
252
+
<h2align="center">What tile should look like</h2>
253
+
<p>
254
+
Tile is any square image that can be repeated all over map, for example:<br>
To change tile image you just need to save it into ./src/assets/tiles and in ./src/view/tile.js change import img from '../assets/tiles/your_custom_image.png'
260
+
</p>
261
+
<p>
262
+
Same steps can be applied to collective creating, save collective image to ./src/assets/collective and replace import in collectives.js
263
+
</p>
264
+
<p>
265
+
Some folder and file naming can differ depending on game, for example, collective folder and file in plantSavior game calling plant.js
0 commit comments