Re: Shooting Multiple Bullets

new topic     » goto parent     » topic index » view thread      » older message » newer message
 
atom Width=1024  
atom Height=720  
constant X = 1, Y = 2 
  
InitWindow(Width,Height,"Shump")  
  
SetTargetFPS(60)  
  
atom black = bytes_to_int({0,0,0,0})  
  
atom red = bytes_to_int({255,0,0,255})  
  
atom bullet_speed = 0.030  
  
sequence bullets = {}  
  
while not WindowShouldClose() do  
  
    if IsKeyPressed(KEY_SPACE) then  
 
        atom bullet_x = GetScreenWidth() / 2  
        atom bullet_y = GetScreenHeight() / 2  
        bullets = append(bullets, {bullet_x, bullet_y}) 
         
    end if  
  
    for i = length(bullets) to 1 by -1 do 
     
        bullets[i][X] += bullet_speed  
         
        if (bullets[i][X] >= GetScreenWidth()) then  
         
            bullets = remove(bullets, i) 
            continue 
             
        end if  
          
        BeginDrawing()  
          
        ClearBackground(black)  
 
        DrawCircleV(bullets[i][X], bullets[i][Y], 20, red)  
          
        EndDrawing()  
 
    end for 
  
end while  
  
CloseWindow() 
 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu