Post your minigame

BlitzMax Forums/BlitzMax Programming/Post your minigame

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.

Here's a thread for any minigame you've created. A good place to test your game idea too.

I'll start with my game, where you control two players at once. Since they start at different directions, they will always travel in different direction! You must reach both white tiles at the same time to complete the game.



SuperStrict
AppTitle = "Small game"
Const GfxWidth:Int = 640,GfxHeight:Int = 480
Graphics GfxWidth,GfxHeight,0

Const Radius:Int = 32

Type Player
	Field X:Float,Y:Float,Angle:Float
	Global PlayerList:TList
	Method New()
		ListAddLast(PlayerList,Self)
	End Method

	Function TurnLeft()
		For Local P:Player = EachIn Player.PlayerList
			P.Angle:-5
		Next
	End Function

	Function TurnRight()
		For Local P:Player = EachIn Player.PlayerList
			P.Angle:+5
		Next
	End Function

	Function Forward()
		For Local P:Player = EachIn Player.PlayerList
			P.X:+Cos(P.Angle)
			P.Y:+Sin(P.Angle)
		Next
	End Function

Function Backward()
		For Local P:Player = EachIn Player.PlayerList
			P.X:-Cos(P.Angle)
			P.Y:-Sin(P.Angle)
		Next
	End Function

	Function Draw()
		For Local P:Player = EachIn Player.PlayerList
			SetColor 128,128,255
			DrawOval P.X-Radius*0.5,P.Y-Radius*0.5,Radius,Radius
			SetColor 255,255,255
			DrawLine P.X,P.Y,P.X+Cos(P.Angle)*Radius*0.5,P.Y+Sin(P.Angle)*Radius*0.5,0
		Next
	End Function
End Type
Player.PlayerList = CreateList()

Local Map:Int[GfxWidth/Radius,GfxHeight/Radius]
SetClsColor 0,0,0

Map[4,4] = 1; Map[4,5] = 1; Map[4,6] = 1; Map[9,9] = 1; Map[10,9] = 1; Map[11,9] = 1
Map[5,6] = 1; Map[6,6] = 1; Map[7,6] = 1; Map[11,8] = 1; Map[11,7] = 1; Map[11,6] = 1
Map[8,6] = 1; Map[9,6] = 1; Map[10,6] = 1; Map[11,5] = 1; Map[11,4] = 1; Map[11,3] =1;
Map[11,2] = 1; Map[12,2] = 1; Map[13,2] = 1; Map[14,2] = 1; Map[15,2] = 1; Map[16,2] = 1
Map[11,10] = 1; Map[11,11] = 1; Map[16,1] = 1; Map[16,0] = 2; Map[12,11] = 1; Map[13,11] = 2
Map[5,4] = 1; Map[6,4] = 1; Map[7,4] = 1; Map[8,4] = 1; Map[9,4] = 1; Map[10,4] = 1;
Map[3,4] = 1; Map[2,4] = 1; Map[1,4] = 1; Map[0,4] = 1; Map[4,3] = 1; Map[4,2] = 1
Map[5,2] = 1; Map[6,2] = 1; Map[7,2] = 1; Map[8,2] = 1; Map[9,2] = 1; Map[10,2] = 1
Map[8,9] = 1; Map[7,9] = 1; Map[6,9] = 1; Map[5,9] = 1; Map[4,9] = 1; Map[3,9] = 1; Map[2,9] = 1
Map[1,9] = 1; Map[0,9] = 1; Map[0,8] = 1; Map[0,7] = 1; Map[0,6] = 1; Map[0,5] = 1; Map[7,8] = 1
Map[7,7] = 1; Map[12,9] = 1; Map[13,9] = 1; Map[14,9] = 1; Map[14,10] = 1; Map[14,11] = 1
Map[12,6] = 1; Map[13,6] = 1; Map[14,6] = 1; Map[15,6] = 1; Map[16,6] = 1; Map[16,5] = 1;
Map[16,4] = 1; Map[16,3] = 1; Map[14,1] = 1; Map[14,0] = 1; Map[15,0] = 1; Map[11,0] = 1
Map[11,1] = 1; Map[12,0] = 1; Map[13,0] = 1; Map[14,8] = 1; Map[14,7] = 1

Local p1:Player = New Player
p1.X = 304; p1.Y = 304; p1.Angle = 180
Local p2:Player = New Player
p2.X = 144; p2.Y = 144; p2.Angle = 270

Repeat
	If KeyDown(KEY_LEFT) Then Player.TurnLeft()
	If KeyDown(KEY_RIGHT) Then Player.TurnRight()
	If KeyDown(KEY_UP) Then Player.Forward()
	If KeyDown(KEY_DOWN) Then Player.Backward()

	Local Reset:Int = 0
	For Local P:Player = EachIn Player.PlayerList
		If Map[Floor(P.X/Radius),Floor(P.Y/Radius)] = 0 Then
			Reset = 1
			Exit
		EndIf
	Next
	If Reset = 1 Then
		p1.X = 304; p1.Y = 304; p1.Angle = 180
		p2.X = 144; p2.Y = 144; p2.Angle = 270
	EndIf

	DrawMap(Map)
	Player.Draw()

	If Map[Floor(p1.X/Radius),Floor(p1.Y/Radius)] = 2 And Map[Floor(p2.X/Radius),Floor(p2.Y/Radius)] = 2 Then
		SetColor 255,255,255
		DrawText "GAME COMPLETE",GfxWidth*0.5-TextWidth("GAME COMPLETE")*0.5,GfxHeight*0.5
		Flip
		Repeat
		Until KeyHit(KEY_ESCAPE)
		End
	EndIf

	Flip
	Cls

Until KeyHit(KEY_ESCAPE)

Function DrawMap(Map:Int[,])
	For Local x:Int = 0 To GfxWidth/Radius-1
		For Local y:Int = 0 To GfxHeight/Radius-1
			If Map[x,y] = 1 Then
				SetColor(128,128,128)
				DrawRect x*Radius,y*Radius,Radius,Radius
			ElseIf Map[x,y] = 2 Then
				SetColor(255,255,255)
				DrawRect  x*Radius,y*Radius,Radius,Radius
			EndIf
		Next
	Next
End Function