forum-msg-id-134751-edit

Original date:2020-02-08 04:23:49 Edited by: Maccuq Subject: Re: Shooting Multiple Bullets

 
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], bullet_y, 20, red)  
          
        EndDrawing()  
 
    end for 
  
end while  
  
CloseWindow() 
 
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu