JS13K Games 2019 Day 26
Wow! My brain is coming up with a lot of ideas for Shield Bearer tonight (12:27am on 9/7/2019)! I just came up with a good idea: variable jumping height! How do I implement that in my game? In Jedulz's entry, he uses a variable called dy for change in the y direction. He then has a gravity variable that will increase the dy, because it is negative to send the player upwards, and then the player falls to the ground when dy is positive. I'm thinking, on a "keyup" event for the Up Arrow or W key, we set dy to zero if dy is less than zero. That way the "downward force" of the gravity starts working immediately after releasing Up Arrow or W key. Also, I came up with having that if condition because I don't want the player to be able to release the Up Arrow or W key at any time to restart accelerating to the ground.
I wanted to get my "game over" state set up for later. I'm thinking I'll have a health counter or something. When that health counter reaches zero or less, set running to false; which, will cause the game to stop and go into that "game over" state. I'll just have an alert dialog for now. I did find a nice example of dialog boxes in pure JavaScript. The alert will just say "game over" and give them their score, but I would like to change that so a person can enter their name for a global leader board for the high score.
I then moved on to trying to get the redrawing of the canvas going. I hope that Jedulz doesn't mind that I'm using his code as a reference. I was wondering what was going on in his animate function, so I looked up the requestAnimationFrame function. It looks like he isn't using a set interval to redraw his canvas for his entry, he's just letting requestAnimationFrame do all the work. I feel I should try to see what I can do with my set interval. The Mozilla documentation for requestAnimationFrame looks like that function creates a new object and ID every time it is called. I could put another global variable for those Frames, but I just like the one interval "object" that I can cancel to stop the game. If I run into any issues, I might change my mind.
Well, I've ran into a bug caused by that infinite while loop. Appearently, interval is not ran on another thread. I think I might try switching over to requestAnimationFrame. It's not to hard to convert to that method.
I removed the infinite loop, but the game now goes straight to the "Game Over" state. Nothing is being drawn, and I only managed to set the Canvas (gameWindow) to use the correct size based on Jedulz's entry. Due to my "blog rules", I'm stopping this entry here. I might get back to it, who knows. It's a bit discouraging when your code isn't working, besides the stuff you put in there that is just based on other people's code. Hopefully, I'll feel better later and I'll be able to make some progress on it. It's five days until the deadline and it is not looking good. There are already some people that have finished and uploaded their entries, and my game is nowhere near finished. Granted, I shouldn't feel too bad about that. They're probably seasoned JavaScript Developers, and I'm just a guy using the HTML5 Canvas for the first time.
You know what, I can end on a happy note! I came up with an idea for one of my enemy types: a robot spider! It crawls down from somewhere above the screen, and at an x position where it will be fully visible on the screen once it crawls down into view. Meaning, its starting x position is between 0 and gameWindow.width - bot.width. It will crawl down until it reaches a y position between 0 and canvas.height - bot.height. It won't start attacking the Bearer until it reaches its y destination and stops crawling down. It attacks by shooting projectiles from the middle of its abdomen. This projectile will be fired at an angle so that it travels to the center of the Bearer. They will be somewhat like the enemy ships in my Java game Orion's Revenge. I'm thinking I can animate these robot spiders like Goombas: they're only one sprite, but we flip it every other frame to simulate a crawling motion. Then we simply stop animating the robot spider when it reaches its destination. I'm thinking I could even draw a line from the middle of the spider at the starting position, to the middle of the spider's current position to generate a spider's silk when it is rappelling down from somewhere. I liked the idea of firing projectiles from the spider's abdomen, because I won't have to make sprites for the enemy aiming at the Bearer: players will probably assume the spider's round abdomen is a multi-directional weapon. I even came up with ideas on how to make the robot spiders more difficult as the player gains points: we can have the spiders fire projectiles faster or at random intervals to throw off the player, the spiders can crawl down faster, and/or we can increase the number of spiders that we can have on the screen at once.
I removed the infinite loop, but the game now goes straight to the "Game Over" state. Nothing is being drawn, and I only managed to set the Canvas (gameWindow) to use the correct size based on Jedulz's entry. Due to my "blog rules", I'm stopping this entry here. I might get back to it, who knows. It's a bit discouraging when your code isn't working, besides the stuff you put in there that is just based on other people's code. Hopefully, I'll feel better later and I'll be able to make some progress on it. It's five days until the deadline and it is not looking good. There are already some people that have finished and uploaded their entries, and my game is nowhere near finished. Granted, I shouldn't feel too bad about that. They're probably seasoned JavaScript Developers, and I'm just a guy using the HTML5 Canvas for the first time.
You know what, I can end on a happy note! I came up with an idea for one of my enemy types: a robot spider! It crawls down from somewhere above the screen, and at an x position where it will be fully visible on the screen once it crawls down into view. Meaning, its starting x position is between 0 and gameWindow.width - bot.width. It will crawl down until it reaches a y position between 0 and canvas.height - bot.height. It won't start attacking the Bearer until it reaches its y destination and stops crawling down. It attacks by shooting projectiles from the middle of its abdomen. This projectile will be fired at an angle so that it travels to the center of the Bearer. They will be somewhat like the enemy ships in my Java game Orion's Revenge. I'm thinking I can animate these robot spiders like Goombas: they're only one sprite, but we flip it every other frame to simulate a crawling motion. Then we simply stop animating the robot spider when it reaches its destination. I'm thinking I could even draw a line from the middle of the spider at the starting position, to the middle of the spider's current position to generate a spider's silk when it is rappelling down from somewhere. I liked the idea of firing projectiles from the spider's abdomen, because I won't have to make sprites for the enemy aiming at the Bearer: players will probably assume the spider's round abdomen is a multi-directional weapon. I even came up with ideas on how to make the robot spiders more difficult as the player gains points: we can have the spiders fire projectiles faster or at random intervals to throw off the player, the spiders can crawl down faster, and/or we can increase the number of spiders that we can have on the screen at once.
Comments
Post a Comment