platform example?

BlitzMax Forums/BlitzMax Beginners Area/platform example?

Hi, does any complete example of a game of platform exist like "super mario bros"?

There is a platform example in de example files that come with BlitzMax.


Nicolas.

the examples are only these!
are there other examples?

option in the 'Program' menu.
Rockout - Great original game idea
BlitzOut - Breakout style game demo
StarfieldPong - Pong in space
Digesteroids - Crumbs! this game takes the biscuit
Old Skool2 - Flashback to the good old days
AStar demo - Demo of the classic AI algorithm
Fireworks - Cool fireworks effect using additive blending
Snowfall - Simple but effective blizzard effect
CircleMania - Vector balls revisited!
Firepaint - Glowy particle effects
Fireworks - Kaboom!
Viewport - Bouncing viewport demo
Shadow Image - Simple 2D shadow demo
Inertia - Simple rotate and thrust code example
RadialBlur - Example of color and blending effects
Tempest - Quick version of the classic arcade game
Tiledrop - Puzzle style game demo
Zombieblast - Deal yet again to those irksome zombies!
FilmClip - Nice 'retro' effect
GLBlurr - Bizarro blur effect
LightImage - Simple 2D lighting demo

There is one hidden in 'samples/birdie/games/platform' folder...but it seems a bit broken.

http://www.scottshaver2000.com/forum/viewtopic.php?t=94

scrolling tile map example for use in platformer games

edit: you might have to set the graphics driver if you are using 1.10 version of BMax

Here is a quick "no frills" example for you. I haven't made a platformer in years so the collision response might need some tweaking:

Strict

Const Gravity:Float = 1.0
Global PlatformList:TList = CreateList()


Graphics 640,480,0
SetClsColor 100,150,255

Local p1:Player = Player.Create(320,240)

Platform.Create(320,300)
Platform.Create(320,100)
Platform.Create(250,200)

Platform.Create(320,400,700,80)
While Not KeyHit(KEY_ESCAPE)
	Cls
	
	For Local p:Platform = EachIn PlatformList
		p.Render()
	Next
	p1.Update()
	p1.Render()
	
	Flip
	FlushMem
Wend


Type Platform
	Field X:Float
	Field Y:Float
	Field Width:Int
	Field Height:Int
	
	Function Create:Platform (_X:Float, _Y:Float, _Width:Int = 64, _Height:Int = 16)
		Local p:Platform = New Platform
		p.X = _X
		p.Y = _Y
		p.Width = _Width
		p.Height = _Height
		PlatformList.AddLast(p)
		Return p
	End Function
	
	Method Render()
		SetColor 0,128,0
		DrawRect X-(Width/2),Y,Width,Height
	End Method
	
End Type

Type Player
	Field X:Float
	Field Y:Float
	Field VX:Float
	Field VY:Float
	Field Width:Int
	Field Height:Int
	Field Controls:Int [4]
	
	Function Create:Player (_X:Float, _Y:Float, _Width:Int = 32, _Height:Int = 64)
		Local p:Player = New Player
		p.X = _X
		p.Y = _Y
		p.Width = _Width
		p.Height = _Height
		p.Controls = [KEY_UP,KEY_LEFT,KEY_RIGHT]
		Return p
	End Function
	
	Method Render()
		SetColor 255,128,0
		DrawRect X-(Width/2),Y-Height,Width,Height
	End Method
	
	Method Update()
		If KeyDown(Controls[1]) Then VX :+ -1 'LEFT
		If KeyDown(Controls[2]) Then VX :+ 1 'RIGHT

		'I'm most likely not using the best method
		'for jumping or collision response here
		If KeyHit(Controls[0]) And VY >= 0
			VY = -15
		End If

		Y :+ VY
		X :+ VX
		VY :+ Gravity
		VX :+ (0 - VX) * .05
		Local P:Platform = CollidedWithPlatform()
		If P
			If Y < P.Y + P.Height And Y > P.Y And VY > 0 Then
				Y = P.Y
				VY = 0
			End If
		End If
		
	End Method
	
	Method CollidedWithPlatform:Platform()
		For Local p:Platform = EachIn PlatformList
			If (p.X + p.Width/2 < X - Width/2)	Continue
			If (p.X - p.Width/2 > X + Width/2) Continue 
			If (p.Y + p.Height < Y - Height) Continue
			If (p.Y > Y) Continue 
			Return p
		Next
	End Method
End Type


thanks to all :)