Hacking Bitsy to run AI PT. 2: Ghosts N Stuff
Click to play game Welcome to the second part where I will be going over the actual AI / game programming, and how I got it to interface with Bitsy. If you haven't read the first part, you can find it here Communicating between Bitsy and our Code. This game uses the standard start/update function convention (named pStart() , and pUpdate() respectively in the code). I lodged the pStart() function call right after load_game() in the startExportedGame() function. so that it is called first thing, but also after all the game data has been initialized. It's job is to simply set up our own game variables and objects. Then I called the pUpdate() function in two places. Once at the end of pStart() in the form of a "setInterval" which is set to update every 300 miliseconds, and a special world.player.update() (more on this in a second) was forcefully stuffed into Bitsy's updateInput() function to update the player position every time a key is pres