Share your repls and programming experiences

← Back to all posts
Space Shooter
CursorsDev

Move your unrealistic ship and shoot unrealistic lasers at unrealistic enemy ships that are also the same unrealistic shape as yours!

  • WASD to move
  • Space to shoot

Triangle collision was too hard to implement so I took the obvious fix: use rectangular bounding boxes and make them smaller.

Voters
ZakirMansuri
coderdude666
06rha1504
E-Sheep
TheOceanFace
littlepenguin
commander5424
SeamusDonahue
LordPancake
Rumble330
Comments
hotnewtop
Gabby8C0des8

my brother came in and asked why a big white triangle was shooting the poor doritos :))

lightningrock

tankerguy1917

@lightningrock ddddddddaaaaaaaaannnnnnnggggggg, thats what i call dedication.

lightningrock

played for 2h straight. (●'◡'●) @tankerguy1917

realTronsi

The collision is pretty glitchy, an easier way is to first detect line intersections and then determine if the shapes are inside each other. (I have a demo of that here: https://phy2d-demo.realtronsi.repl.co/)

CursorsDev

@realTronsi that's sick :)

CursorsDev

hello people

potatojs

hello cursors
@CursorsDev

NicholasWhite6

@CursorsDev
is there a way you can make the enemy shoot back as well

TheOceanFace

wow cool

CursorsDev

well i guess i will make it harder. i guess im just bad at my own game rip :)

SeamusDonahue

the movement is really smooth! Add more enemy types/more difficulty though, as of now I can't really play this for more than a minute. I really think this is cool though

gibbsfreenergy

This is such an awesome game! I could play for hours.

tankerguy1917

this looks great and works perfectly as far as i know

RolandJLevy

@CursorsDev well done - this is a great game! The movements are nice and fluid.

Maybe you could use some more detailed graphics for the spaceships, in SVG format? You can download free SVGs here: https://freesvg.org/cartoon-spaceship

realTronsi

Found a bug where if you leave it on and switch to another tab, enemies will keep spawning. requestAnimationFrame() stops working when you switch tabs to conserve battery, so your main loops, which I'm assuming use requestAnimationFrame, will pause after you switch tabs, but I'm guessing your enemy spawning loop uses setInterval().

This is a minor bug, but I'd suggest putting the enemy spawning mechanism in the requestAnimationFrame as well. Otherwise depending on computer speed and other factors, enemy spawning will not be consistent

FloCal35

Honestly I think it needs to be a LITTLE harder

CursorsDev

@FloCal35 alr doubling unrealistic enemy ship speed and health

FloCal35

@CursorsDev Perfect

FloCal35

Unrealistic lol