Re: Bullet Issue

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thanks that was it. It was refreshing as it drawing over the bullets.I made a few modifications. It works. Now I just need to add a small timer delay so the bullets don't get fired too fast.

include std/ffi.e  
include raylib.e  
  
atom Width = 1024  
atom Height = 720  
  
InitWindow(Width,Height,"Bullets")  
  
SetTargetFPS(60)  
  
atom bullet_speed = 1.0  
  
sequence bullets = {}  
  
integer bullet_visible = 0  
 
constant X = 1, Y = 2 
  
sequence bullet_pos = {GetScreenWidth() / 2, GetScreenHeight() / 2} 
atom bullet_x = GetScreenWidth() / 2 
atom bullet_y = GetScreenHeight() / 2  
 
  
while not WindowShouldClose() do  
  
	if IsKeyPressed(KEY_SPACE) then  
		bullets = append(bullets,{bullet_x,bullet_y})  
	 
		bullet_visible = 1  
	end if  
	  
	BeginDrawing()  
	 
	ClearBackground(BLACK) 
	 
		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  
		 
		if bullet_visible = 1 then  
		--ClearBackground(BLACK) 
		DrawCircleV({bullets[i][X],bullets[i][Y]},20,RED)  
		end if  
	end for  
  
	 
	DrawCircleV(bullet_pos,20,GREEN) 
  
	EndDrawing()  
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