I worked on this on and off for a long time, and had to come up with a lot of unorthodox techniques to get everything working. I'm thinking about writing a blog entry explaining the code, as I've had someone ask about how the systems work.
As for the invaders speeding up, that was actually one of the simpler things to implement. There's a constant value --in this case 3-- that is divided by the number of invaders remaining to give the distance they move horizontally each frame. When only one is left, it's going 45 times as fast as it did to start.
I would say that if you're starting out on the idea, getting it done in the next few days could be hard, but go for it if you want to. You can go ahead and use code from this one if you can understand it, though it's super compressed. Here's a really useful piece, though, that's slightly simplified from the version in the cart.
ˇ-=4b=btn()p+=b%4-b%2*3if(b\9*ˇ<0)x=p+2ˇ=k
That one line contains basically all the logic for the movement of both the player ship and its projectiles. I'll break it into a few parts to explain.
ˇ-=4 This moves the single player bullet up 4 pixels every frame. The "ˇ" symbol, which represents the bullet's y position, doesn't have to be initialized because before it's given a value, it already has a negative one. (it's the only symbol like this that doesn't count as two chars on Twitter, though, as far as I know).
b=btn()p+=b%4-b%2*3 This moves your ship's horizontal position, "p", using the left/right keys
if(b\9*ˇ<0) This allows a bullet to be fired if the last one is off screen and you press the Z or X key (well, there's only one, so it lets it be re-fired).
x=p+4ˇ=k This aligns the bullet x and y positions with those of your ship (represented by p and k), putting it in firing position. Since it automatically moves up, it looks like it's being shot.
You're welcome. I like breaking things down and helping people understand it. I know I have to do that a lot for myself.
For vertical movement you can just extend the same concept to the values of 4 and 8, like this:
x+=b\2%2-b%2y+=b\8%2-b\4%2
It's the same pattern for every button, but you can simplify the expression for button 0. I initially used a slightly different method, with a swapped order of the floor divide and modulus operators, but that took an extra character or two.
As for waiting till next year, the tweettweet jams are roughly every 6 months, so you might still make it this year. =)
Super impressive! I tried years ago to also make a Space Invaders for the TweetTweetJam with far less success, where here the game looks like the original up to the invaders going faster as there's less of them. Great work!
← Return to game
Comments
Log in with itch.io to leave a comment.
Thank you very much,
I worked on this on and off for a long time, and had to come up with a lot of unorthodox techniques to get everything working. I'm thinking about writing a blog entry explaining the code, as I've had someone ask about how the systems work.
As for the invaders speeding up, that was actually one of the simpler things to implement. There's a constant value --in this case 3-- that is divided by the number of invaders remaining to g
ive the distance they move horizontally each frame. When only one is left, it's going 45 times as fast as it did to start.Thank you,
I would say that if you're starting out on the idea, getting it done in the next few days could be hard, but go for it if you want to. You can go ahead and use code from this one if you can understand it, though it's super compressed. Here's a really useful piece, though, that's slightly simplified from the version in the cart.
ˇ-=4b=btn()p+=b%4-b%2*3if(b\9*ˇ<0)x=p+2ˇ=k
That one line contains basically all the logic for the movement of both the player ship and its projectiles. I'll break it into a few parts to explain.
ˇ-=4 This moves the single player bullet up 4 pixels every frame. The "ˇ" symbol, which represents the bullet's y position, doesn't have to be initialized because before it's given a value, it already has a negative one. (it's the only symbol like this that doesn't count as two chars on Twitter, though, as far as I know).
b=btn()p+=b%4-b%2*3 This moves your ship's horizontal position, "p", using the left/right keys
if(b\9*ˇ<0) This allows a bullet to be fired if the last one is off screen and you press the Z or X key (well, there's only one, so it lets it be re-fired).
x=p+4ˇ=k This aligns the bullet x and y positions with those of your ship (represented by p and k), putting it in firing position. Since it automatically moves up, it looks like it's being shot.
You're welcome. I like breaking things down and helping people understand it. I know I have to do that a lot for myself.
For vertical movement you can just extend the same concept to the values of 4 and 8, like this:
x+=b\2%2-b%2y+=b\8%2-b\4%2
It's the same pattern for every button, but you can simplify the expression for button 0. I initially used a slightly different method, with a swapped order of the floor divide and modulus operators, but that took an extra character or two.
As for waiting till next year, the tweettweet jams are roughly every 6 months, so you might still make it this year. =)
Super impressive! I tried years ago to also make a Space Invaders for the TweetTweetJam with far less success, where here the game looks like the original up to the invaders going faster as there's less of them. Great work!