New comers to Blitz read please:

Blitz3D Forums/Blitz3D Beginners Area/New comers to Blitz read please:

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

This is a verry simple game I started a long time ago, kinda like space invaders but a... not.
It works but has some major bugs I could not work out before I lost interest. I think this was my first forom post ever and someone told me it was a promising simple game. So is this what you mean Ross C?


Graphics 640,480 
SetBuffer BackBuffer() 
SeedRnd (MilliSecs ()) 
; make random boxes fall and if one reaches the bottom you loose 

Print "this is a game by matt anthony" 
Global target_hit
Global leval



leval=leval+1

Type player 
Field x 
Field y 
Field r,g,b 
End Type 

Type rocks 
Field x 
Field y 
Field r,g,b 
Field fallrate ; alien's fall rate 
End Type 

Type bullet 
Field x 
Field y 
Field r,g,b 
Field bulletrate 
End Type 
.start


Global totalrocknumber= 5+leval
Global rocknumber = totalrocknumber 
For a = 1 To rocknumber 

rock.rocks = New rocks 
rock\x = Rnd(20,620) 
rock\y = 0 
rock\fallrate = Rnd (-1,1.5) + Rnd(1.3,2.8) 
rock\r=Rnd(100,255) 
rock\g=Rnd(1,255) 
rock\b=Rnd(1,255) 

Next 

player.player=New player 
; Colour: 

player\r = 25 
player\g = 0 
player\b = 200 

player\x = 320 
player\y = 440 
Rect player\x, player\y, 50, 10, 1 
Color 255, 255, 255 
Text player\x+80, player\y, "Player 1" 






atbottom=0

WaitKey() 
;start of mainMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 
While Not KeyHit(1) 
;Cls 
For moveall.rocks = Each rocks 
Delay 10 
moveall\y = moveall\y + moveall\fallrate  
Color rock\r, rock\g, rock\b 
Rect moveall\x, moveall\y, 20, 25,0 ; Draw each invader 
Next 

;If moveall\y > 480 Then atbottom = 1 ; If any are at bottom of screen, end! 
If atbottom=1 Then 
  Print "Game over! The earth is in ashes!":Delay 5000:Print "Hope your happy." 
End If



;203=left,205=right 
If KeyDown(203) player\x=player\x-15 
If KeyDown(205) player\x=player\x+15 
Color player\r, player\g, player\b 

Rect player\x, player\y, 50, 10, 1 
Rect player\x+5, player\y-8,40,8,1 
Rect player\x+20, player\y-16,10,8,1 

If KeyHit (57) 
CreateBullet(player\x,player\y) 
EndIf 
UpdateBullets() 



Flip 
Cls 

Wend 
;End of mainMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 


Function CreateBullet(x,y) 
	;Create a new bullet 
	bullets.bullet = New bullet 
	bullets\x = x+23 
	bullets\y = y-20 

	;bullets\bulletrate=-4 
End Function 

Function UpdateBullets() 
	For bullet.bullet=Each bullet 
		bullet\y=bullet\y-5 

		Color 255,200,200 
		Rect bullet\x,bullet\y,3,20,1 
		Color 0,0,200 
		Rect bullet\x,bullet\y+12,3,6,1 
		Color Rnd (100,255), Rnd (100,255),0 
		Rect bullet\x,bullet\y+16,3,6,1 

		For moveall2.rocks = Each rocks 
			If RectsOverlap (bullet\x,bullet\y,3,20,moveall2\x,moveall2\y,20,25) Then 
				;If RectsOverlap ......
				Text 100,100,"rects overlaped"
				

;target_hit=0

				target_hit=target_hit+1
				If target_hit>0 Then
				Delete moveall2.rocks
				;Delete moveall.rocks
					Print "target_hit=1"
					

 				EndIf
			EndIf 

		Next	

	If bullet\y < 0 
	

	Delete bullet
	EndIf
	

Next 

target_hit=0

End Function 

Function clear(atbottom)
For d.bullet = Each bullet
 Delete d
Next

For e.rocks = Each rocks

Delete e
Next

For p.player = Each player
Delete p
Next

atbottom=False


target_hit=0
Cls
FlushKeys
Text 400,10,"atbottom="+ atbottom

;moveall\y=0
End Function