Moving (bouncing) platform- Ver. 4.1.5

weapon121

Member
Hello guys!

I couldn't find any topic pertaining to this, so if there is one, please let me know!

So this started out as an experiment, and became a full blown obsession. I needed a simple moving platform. I was going to create some clouds or blobs, that when jumped on, could be used as a platform. Finally got something I was happy with.

Now, I did start working on a traditional version of a moving platform and got it working somewhat, but it needed some more work to get it right and I have much more stuff to do, So for now, anyone with much more knowlege than me at this point can probably get it fully working.The code I started is commented out at the bottom. It pretty much holds the main player in place by setting the gravity bit and putting him in the "ladder" state. The player then follows whatever direction the platform is going, through a defined user variable " platformMove" . You would have to work in the Physics script im guessing to make it play nice with the Changestates and the Phisics...If anybody gets this fully working, please let me know!


ezgif.com-video-to-gif.gif


ezgif.com-video-to-gif (1).gif

It works great verticaly also!

ezgif.com-video-to-gif (2).gif

ezgif.com-video-to-gif (3).gif

Its actually very simple to implement:

Create a monster and call it whatever you want. (Myne is called m_Platform)

Make sure its a Monster Type. Set acceleration to the max. The rest depends on your own use. In my case, I have it bouncing back and forth when it reaches the edge of the screen.

PlatformDetails.jpg

Make sure :

Immune to weapon is selected ( You dont want to kill yourself mid air if you hit it with your weapon! LOL)
No hurt recoil and Ignore gravity is selected. The rest depends on your own settings. In my case I have it starting to move left and then it goes to the next action, where it loops in place.

Platform_Actions.jpg


Next, open your" HandleObjectCollisions.asm " script located in the" GameEngineData\Routines\"Whatever module you are using\ModuleScripts\MainScripts\SimplePlatformer " .

At around line 170, after this:

Code:
otherIsAMonsterTypeCollision:

Add this:

Code:
	;;;;;;;;;;;;;;;;;;;;;;;;;;add this for "platform monster"
	LDA Object_type,x  ;; Is it a platform?
	CMP #37				;;replace this number with the number for your platform monster
	BNE +
	jmp standOnP  ;; jump to code that controls "platform" behaviour if it's a platform monster 
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	+

What this does is essentially omitts the monster hurting you, but with the benefit of detecting its collision with you. Instead, it takes you to a routine called "standOnP " ( I know, sounds kind of weird...LOL).

After the very last RTS you find, paste this:

Code:
standOnP :
	
	LDY player1_object  ;; The other Object is in register "X" , so we load the player Object into the " Y " register instead.
	LDA Object_y_hi,x ;; We want to make sure that the player is above the platform , if he isnt, he falls off/through. 
	SEC
	SBC #$08		;; change this if you want him to be even higher than currently set.
	STA temp3
	LDA Object_y_hi,y
    	CMP temp3
	BCC +
	RTS
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	+
	;LDA Object_physics_byte,y ;;;;;;;; make sure gravity is off for NON-Gravity solution
    	;ORA #%00000010			;;;;;;;;;
    	;STA Object_physics_byte,y ;;;;;;;;;;;
	GetCurrentActionType player1_object
	CMP #$02
	BEQ +
	ChangeObjectState #$02, #$04
	+
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;; If pressing "A" , Jump from platform ;;;;;;;;;;;;;;;;;;;;;;;;;
	LDA gamepad
	AND #%00000001
	BEQ +
	LDA #JUMP_SPEED_HI
	STA temp
	LDA #JUMP_SPEED_LO
	STA temp1
	PlaySound #SND_JUMP
	JMP ++
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Bounce on platform to keep it from falling through ;;;;;;;;;;;;;;;;;;;;;;;;
	+
	LDA #$02
	STA temp
	LDA #$03
	STA temp1
	++
	LDA #$00
	SEC
	SBC temp1;#3;JUMP_SPEED_LO
	STA Object_v_speed_lo,x
	LDA #$00
	SEC
	SBC temp;#2;JUMP_SPEED_HI
	STA Object_v_speed_hi,x
	RTS
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;LDA Object_y_lo,y									;;	The remainder of this code is "Off" since im using gravity. However, 
    	;SEC
    	;SBC #LADDER_SPEED_LO 
    	;STA Object_y_lo,y
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; From this point on,uncomment if you wish to try and work on a NON-Gravity solution

	;LDA platformMove  ;;  Create this user variable and place it somewhere it can be incremented/decremented
    	;CMP #$01		   ;; If going Left, speed is negative
    	;BNE +			   ;; Else, move positive
	
	;LDA #$00
	;STA Object_h_speed_lo,y
	;LDA #$04
	;STA Object_h_speed_hi,y
	;RTS
	
	;JMP ++
	;+
	;LDA #$FF
	;STA Object_h_speed_lo,y
	;LDA #$FE
	;STA Object_h_speed_hi,y
	;RTS
	;++
	
	;RTS

And thats pretty much it! Please let me know if anything. One thing though, I have patched and applied some changes to many of the base scripts. Plaese make sure you have at the VERY MINIMUM this fix from Dale Coop for fixing the Ignore gravity with monsters that fly around! If you havent, try it first to see if you dont need it.....and as always, BACKUP YOUR FILES BEFORE you edit any of the scripts ;)

********************************* "Ignore Gravity" Post ******************************************

http://nesmakers.com/viewtopic.php?f=35&t=1939
 

WillElm

New member
whoa, I've been on and off trying to get something like this for a while now. I've ended up accidentally inventing all kinds of other behaviors. I did manage to come up with something sorta similar but it's not nearly as tight as this. thanks for posting.
 

weapon121

Member
WillElm said:
whoa, I've been on and off trying to get something like this for a while now. I've ended up accidentally inventing all kinds of other behaviors. I did manage to come up with something sorta similar but it's not nearly as tight as this. thanks for posting.

LOL! Thats the best kind of development! 50% of some of the best things I come up with, are "mistakes". Hope it comes in handy!
 

weapon121

Member
Eu percebi que o HUD tem um campo Boss? Era uma vida de chefe? como você conseguiu atribuir um script?
Hello! LOL, just saw this! Ive been stuck with my game for ever, so I was totaly away from pretty much everything! I believe you asked about the boss ? im actually going to implement that in a couple weeks...Ill let you know how i did it if you haven't figured it out yet ;)
 

Jonny

Well-known member
@weapon121 love it. I'm thinking of using this as the basis for other moving platforms too, like fall away ones. Did you use variation of this for your fall away platforms?
 

weapon121

Member
@weapon121 love it. I'm thinking of using this as the basis for other moving platforms too, like fall away ones. Did you use variation of this for your fall away platforms?
The fall away platforms are actually tiles. Once you collide with them, they are changed to null and a "debris" object is created at the tiles x-y coordinate ;) I was eventualy going to create regular moving platforms, but got caught up working on the rest of the game. but this should be "relatively" easy to convert to those. Let me know what you come up with! :)
 

Jonny

Well-known member
The fall away platforms are actually tiles. Once you collide with them, they are changed to null and a "debris" object is created at the tiles x-y coordinate ;) I was eventualy going to create regular moving platforms, but got caught up working on the rest of the game. but this should be "relatively" easy to convert to those. Let me know what you come up with! :)

To be honest, my first attempt was exactly as you just described but having a few tiles in a line, when player ran across the timing was all wrong. Got some quite comical results. I'll try again at some point.
 

weapon121

Member
@weapon121
Hoping you may see this, and wondering if you ever landed on a less bouncy version ?
Hello!

Haven't really messed with this since Ive been working to FINALY release my game, lol . To tell you the truth, Ive messed arouind with so much of the code that if I do get it working like a regular moving platform, its most likely because of all that messing around. For instance, there is an area in my game where you fly, so I negate the gravity there (and some other actions in other scripts etc.) and all I would need to do in that case is just have the player follow the platform as it moves. Im almost done with some bugs and finalizing the box,manual etc. Once I get that done, ill see if I can get it working and then post it ;)
 
Top Bottom