My First Game

Community Forums/Showcase/My First Game

Shuffles(Posted 2011) [#1]
Hello everyone! This is my first game in Blitz3D. Remember it is not commercial quality. The point of this game is to move your cyclops left and right. You then want to shoot the coins with your coin bag to gain points. If you miss the coins, you lose points. If the coins go behind you, you lose lives. Tell me what you guys think. :)

Download for the game: http://www.megaupload.com/?d=XLJMP83Q


Graphics 640,400


;constant variables that won't change
Const uparrow = 200
Const downarrow = 208
Const leftkey = 203
Const rightkey = 205
Const spacebar = 57

;______________Images-----------------
Global stickmancyclops = LoadImage("StickmanCyclops.bmp");the stickman cyclops himself...
MaskImage stickmancyclops,0,0,0

Global CoinBagImage = LoadImage("coinbag.bmp")
MaskImage CoinBagImage,0,0,0

Global CoinImage = LoadImage("coin.bmp")
MaskImage CoinImage,0,0,0

;______________Types------------------
Type CyclopsType
Field x,y
End Type 

Type CoinBagType
Field x,y
End Type 

Type CoinType 
Field x#,y#
End Type 
;------------------------------------


Global cyclops.CyclopsType = New CyclopsType 
 cyclops\x = 260
 cyclops\y = 300


Global coinspeed# = 0.5
Global CoinSpawnRate# = 0
Global Level = 1
Global LevelGap = 20000
Global NextLevel= MilliSecs() + LevelGap
Global Points = 0
Global Lives = 3


SetBuffer BackBuffer()

SeedRnd MilliSecs

;--------------------MAIN LOOP---------------------
While Not KeyDown(1)
	
	
		If MilliSecs() > NextLevel
    		NextLevel = MilliSecs() + LevelGap
    		Level = Level + 1
			coinspeed = coinspeed + 0.5
		EndIf
		
		
		CoinSpawnRate = CoinSpawnRate + 2
		
		
		If Lives <= 0 
			Print "YOU LOSE!"
			Delay 5000
			End
		EndIf 
	  
		
		Cls 
		
		Text 550,15,"Lives:" + Lives
		Text 550,0,"Points:" + Points
		DrawImage stickmancyclops,cyclops\x,cyclops\y

		MoveCyclops();the function that moves the stickman cyclops...
		CreateCoinBagandCoins();function which creates the balls
		UpdateCoinBagandCoins();function which updates the balls once they're created
	
	Flip

Wend 
;-------------END OF MAIN LOOP----------------

Function MoveCyclops();moves the STICKMAN CYCLOPS!

	If KeyDown(leftkey) Then cyclops\x = cyclops\x - 7
	If KeyDown(rightkey) Then cyclops\x = cyclops\x + 7

End Function

;FUNCTION WHICH CREATES THE BULLETS AND BLOCKS
Function CreateCoinBagandCoins()


	If KeyHit(spacebar)
		coinbag.coinbagType = New CoinBagType 
		coinbag\x = cyclops\x + 50
		coinbag\y = cyclops\y + 18
	EndIf 
	
	
	If CoinSpawnRate >= 120
		coin.coinType = New CoinType
		coin\x# = Rand(3,550)
		coin\y# = Rand(3,150)
	EndIf 

	
	
	If CoinSpawnRate >= 120 Then CoinSpawnRate = 0
	

End Function 



;FUNCTION WHICH UPDATES THE BULLETS AND BALLS
Function UpdateCoinBagandCoins()

For coinbag.coinbagType = Each CoinBagType
	coinbag\y = coinbag\y - 4
	DrawImage CoinBagImage,coinbag\x,coinbag\y
    	

	For coin.cointype = Each CoinType
		If ImagesOverlap(CoinImage,coin\x,coin\y,CoinBagImage,coinbag\x,coinbag\y) 
			Delete coin
			Delete coinbag
			Points = Points + 1
			Exit 
		EndIf

	Next	

	
	If coinbag <> Null 
		If coinbag\y < -12 Then Points = Points - 1
		If coinbag\y < -12 Then Delete coinbag
	EndIf 

Next
		


	
	For coin.cointype = Each CoinType

		coin\y = coin\y + coinspeed
		
		DrawImage CoinImage,coin\x,coin\y
			
			If coin\y > 400
				Lives = Lives - 1
				Delete coin
			EndIf 	

	Next 		
		
 
		
End Function 



Last edited 2011


Nate the Great(Posted 2011) [#2]
I couldn't run it because it couldn't find the images...

(im not a mod but this is my advice)
before you post a game in this forum, ideally you should have it compiled into an executable or at least put it as a downloadable zip file. That way we can just download and run your file instead of having to figure out what to do with the code you posted. I suggest packaging up the executable along with the images in a zip file and upload them to filefront (actually i think its called gamesfront now) and post a link to the download here. It would also be a good idea to upload screenshots of the game to let people know what they are downloading otherwise it could be anything. Hope this helped!

On another note I think this is really too short and simplistic to be here and may be better off in the blitz3d programming section so you can get suggestions on the code etc. Keep up the good work though!

Last edited 2011


Shuffles(Posted 2011) [#3]
Oh yeah this isn't for entertainment or anything. Just a simple game. Which happens to be the first real game I've created.


GaryV(Posted 2011) [#4]
You should consider uploading each image to tinypic.com or some other site and post the urls in the thread with your code so people can download the images and run your code without having to create the necessary images themselves.


Shuffles(Posted 2011) [#5]
Alright I now have a download link available.


Canardian(Posted 2011) [#6]
This doesn't work on my LCD, because my LCD allows only certain resolutions:
Graphics 640,400
You could make an .ini file where you read the resolution from, so that it works on all PCs.


Now I got the game to run on my PC, when I added these lines:
; Open the file to Read 
f=ReadFile("game.ini") 
sx=Int(ReadLine(f))
sy=Int(ReadLine(f))
CloseFile(f)

Graphics sx,sy


And in the game.ini file I put the following:
1680
1050


It's a nice little game, and amazingly good considering the small amount of code. But that's why I bought Blitz3D too, because it needs so small amount of coding to make a game :)

Last edited 2011


Shuffles(Posted 2011) [#7]
Thank you!


Nate the Great(Posted 2011) [#8]
wow after playing it is surprisingly good for the small amount of code posted! Unfortunately I think I suck at this game... after 5 minutes of playing I had a high score of 20...

nice game though especially for the code length!


Who was John Galt?(Posted 2011) [#9]
Dang... can't try this because I'm on Mac, but the code looks very tight for a newbie. Congratulations. To be very picky, your code indenting could be improved a bit to make it a little easier reading. Minor point.


Steve Elliott(Posted 2011) [#10]
The code looks very tight. Congrats on your first game, keep at it.


Shuffles(Posted 2011) [#11]
Thank all of you.


Taron(Posted 2011) [#12]
Ooh, very cute! Rock on! I'm somehow anticipating a great evolution here! :o)