Pseudo Code - edSBHS/programmingProjectL3 GitHub Wiki
Pseudo
Player:
player class{ construct set up xpos,ypos,width, height, src(for image),sourceX, sourceY,sourceWidth, sourceHeight,xSpeed } drawimage{ src,sx,sy,sw,sh,x,y,w,h }
player move
if player pressed left key{ x -= xspeed if x is less than 0{ x = canvas width } }(same but opposite for right key pressed)
enemy has hit a me
for Each enemy bullet if has hit enemy { if enemy bullet y pos + ebullet height greater than player ypos{ lives -1 } collided = true } return collided
Enemy
enemy class xpos,ypos,width, height, src(for image),sourceX, sourceY,sourceWidth, sourceHeight,xSpeed, delay, delayrate
draw enemy src,sx,sy,sw,sh,x,y,w,h
enemy move delay + delay rate if delay % 3 = 0 & delay != 0 { x + xspeed delay = 0 }
dropdown xspeed *= -1 y+= h x += xspeed
make enemies variable set up, src,x,y,w,h,sx,sy,xs new enemy(src,sx,sy,sw,sh,x,y,w,h,xs,delay)
push enemy into array
Bullet
bullet class construct xpos,ypos,width, height, colour,xSpeed,
draw bullet fill = colour rect = x,y,w,h
bullet move y-=ySpeed
outof screen return y less than 0 or y is greater than canvas height
has hit enemy return x+w > ex & ex < y+w & y < ey & y < ey + eh
collision for each enemy if hit{ delete that enemy score + 1; } clear array using filter
draw bullet variables, w,h,x,y,ys, colour
new bullet(x,y,w,h,colour,speed) push into bullet array
enemy Bullet
class enemybullet contruct xpos,ypos,width, height, colour,xSpeed,
draw same as bullet
bullet move same as bullet
out of screen if y > canvas height
draw enemy bullet variables w,h,x,y, speed, bullet total // randomize the x, speed and bullet total
for loop i < total new enemyBullet(x,y,w,h,colour,speed) push into array
draw setup
text(x,y,colour,size,text) font = size font fill = colour text = text, x,y
colorRext(x,y,w,h,colour) fill = colour rect = x,y,w,h
draw img(x,y,src,w,h) image = src,x,y,w,h
draw all colorRect 0,0,canvaswidth,canvasheight,black text showing score text showing difficulty imgs showing lives
Main HTML page
//basic set up game canvas width of 500, height of 500 //link other pages