Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
1945 simplified
#1
[Image: ?attachment_id=1703]

Air fighter 1945 in a very very simplified version

The main structure of code is divided in two sections :

1. Initialization
    load image : plane
    load image : bullet
    load image : enemy
    load image : background

2. Main Program (Looping)
    Draw the plane
    Define keys : Esc to quit, Left and Right to move the plane
    Draw enemies
    Bullet is auto shoot

Still have miss lots of features  Big Grin ... somebody please add some code to detect collision between a bullet and an enemy, I am running out of idea on how to code collision detect  Sad

Code:
'INITIALIZATION
set window "1945 Simplified", 640, 480
load image 1,"data/plane.png"
load image 2,"data/bullet.png"
load image 3,"data/enemy.png"
load image 4,"data/black.png"

speed=4
planeX=640/2        ; planeY=400
bulletX = planeX+15 ; bulletY = planeY
enemyX = []         ; enemyY = []
enemyX[0] = 40      ; enemyY[0] = -10
enemyX[1] = 300     ; enemyY[1] = -50
enemyX[2] = 400     ; enemyY[2] = -30

'MAIN PROGRAM
do
    'SET BACKGROUND
     cls
     draw image 4,0,0

     'THE PLANE
     draw image 1,planeX,planeY
                       
    'ESC TO QUIT, LEFT AND RIGHT KEYS TO MOVE THE PLANE
     if keydown(KEY_ESCAPE) then end
     if keydown(KEY_LEFT)   then planeX=planeX-speed
     if keydown(KEY_RIGHT)  then planeX=planeX+speed

     'ENEMIES
     for x=0 to 2
        if enemyY[x]>480 then
            enemyX[x]=rnd(640)
            enemyY[x]=-rnd(50)
         else
            enemyY[x]=enemyY[x]+speed
         endif
      next

      for x=0 to 2
        draw image 3,enemyX[x],enemyY[x]
      next
           
     'BULLET, AUTO SHOOT   
      if bulletY < 480 then
        bulletY   =   bulletY - speed*3
      endif
     
      if bulletY = 100 then
        bulletX = planeX+15
        bulletY = planeY
      endif         
                                
      draw image 2,bulletX,bulletY

     'WAIT BEFORE LOOPING
      wait 40
loop


Attached Files
.zip   1945simplified.zip (Size: 16.2 KB / Downloads: 8)
Reply


Messages In This Thread
1945 simplified - by 1micha.elok - 11-28-2023, 09:17 AM
RE: 1945 simplified - by Marcus - 11-28-2023, 04:46 PM
RE: 1945 simplified - by Marcus - 11-28-2023, 06:17 PM
RE: 1945 simplified - by 1micha.elok - 11-29-2023, 03:49 AM
RE: 1945 simplified - by Marcus - 11-29-2023, 06:01 PM
RE: 1945 simplified - by 1micha.elok - 12-20-2023, 10:18 AM
RE: 1945 simplified - by johnno56 - 11-28-2023, 09:08 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)