[Question] Movement and Scrolling Map Algorithm/Code

Started by
4 comments, last by paul_nicholls 15 years, 6 months ago
Hello Everyone, This is My First Post. Im Learning BlitzBasic And C++/SDL. But im trying to Find Out a tutorial About it. Im trying to make a 2D Platform game "Mario-Like". I Could Make a mario sprite Moving Forward, and Backward but i can make a Good Jump Neither a Map Scrolling (No AutoScrolling). and second things is how to make when "mario" Jump to a [?] Box and that box move a bit to up. My Code Example Moving Forward, BackWard Mario_front = "MarioFront.png" Mario_Flipped = Mario_Front Fliped to Left if BackArrow is Pressed using Mario_Flipped Mario_PositionX = Mario_PositionX - 2 end if if UpArrow is pressed Using Mario_Front Mario_PositionX = Mario_PositionX + 2 end if But i really don't know how make a good Jump. Thanks ^____^
Advertisement
The easiest way to implement a jump is to create an array with how many pixels your character moves per frame and increase that as he gets higher and remove as he gets lower

e.g.

jumpArray = { -1, -2, -3, 0, 3, 2, 1 }mainloop{if isJumping{  ++curJumpFrame  player.y += jumpArray[curJumpFrame]}


Of course, you'll need to cater for if the player has landed on a platform or finished his jump and stop it when necessary
Philip LutasMy site of randomness
That's good way, But Im trying and it's better know but i got some problem.. Mario Is Diggin Instead Jumping. what is wrong. Look Im doing da but in blitz
Dim Jump(7) ; (-2,-4,-8,0,8,4,2)

If Player_Jumping = True Then ; if i press Jump Button

If Jump_pos = 7 Then Jump_pos = 1

Jump_pos = Jump_pos+1

Player_POSY = Player_POSY + Jump(Jump_pos)

DrawImage player_jump, Player_POSX, Player_POSY, player_jump_frame

End If

Thanks
i think you have to move up and then down (jump).

so probably your problem lies in the jump array.
just try switching the sign and it might work correct.

Dim Jump(7) ; (2,4,8,0,-8,-4,-2)
I Understand what you are saying guys, the problem is when i try to put into a Blitz Basic Code... Im Doing Something Wrong.

Im gonna put a sample of what im trying.

Const SCR_W = 640Const SCR_H = 480;AutoMidHandle TrueGraphics SCR_W,SCR_H,16,2SetBuffer BackBuffer()Global Player,Player2,Player_Millisecs, player_frame, Player_POSX#=10, Player_POSY# = SCR_H-131, Player_Moving, Player_Jumping, Jump_pos = 0Global Escape_Key = 1Global LEFT_KEY = 203, RIGHT_KEY = 205, UP_KEY = 200, JUMP_KEY = 57, HIGH_JUMP = 200Dim Jump(7)Player = LoadAnimImage("Mario_Jump2.png",18,28,0,2)MaskImage Player,0,0,0ScaleImage Player, 2.5,2.5Jump(0) = -4Jump(1) = -8Jump(2) = -16Jump(3) =  0Jump(4) =  16Jump(5) =  8Jump(6) =  4While Not KeyHit(Escape_Key)	Cls	Player_Moving = False		If KeyDown (RIGHT_KEY) = True Then				Player_POSX = Player_POSX + 2		Player_Moving = True	End If		If KeyDown (LEFT_KEY) = True Then				Player_POSX = Player_POSX - 2		Player_Moving = True	End If		If KeyDown(JUMP_KEY) = True Then		If Jump_pos = 6 Then Jump_pos = 0		Jump_pos = Jump_pos + 1		Player_POSY = Player_POSY + Jump(Jump_pos)		Player_Jumping = True	End If			DrawImage Player, Player_POSX, Player_POSY, player_frame		If Player_Moving = True Then			Player_Animation()			End If 		Flip	WendEndFunction Player_Animation()	If MilliSecs() > player_MilliSecs + 100 Then		player_millisecs = MilliSecs() ;reset player_millisecs		player_frame = (player_frame +1) Mod 2	End IfEnd Function

Hi Wellimp,
First, welcome to the site :-)

Perhaps this site can help you - it deals with tile based games, and things like jumping.

Tile Based Games

It is written using Flash, but it should still help - it enabled me to start writting a 2d platform game using Delphi/Pascal :-)

cheers,
Paul


This topic is closed to new replies.

Advertisement