Moving (bouncing) platform- Ver. 4.1.5

Post Reply
weapon121
Posts: 39
Joined: Sat Mar 09, 2019 2:45 pm

Moving (bouncing) platform- Ver. 4.1.5

Post by weapon121 » Sun Aug 09, 2020 1:59 am

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.gif (499.54 KiB) Viewed 538 times
ezgif.com-video-to-gif (1).gif
ezgif.com-video-to-gif (1).gif (427.73 KiB) Viewed 538 times
It works great verticaly also!
ezgif.com-video-to-gif (2).gif
ezgif.com-video-to-gif (2).gif (1.08 MiB) Viewed 538 times
ezgif.com-video-to-gif (3).gif
ezgif.com-video-to-gif (3).gif (1.11 MiB) Viewed 538 times
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
PlatformDetails.jpg (56.83 KiB) Viewed 538 times
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
Platform_Actions.jpg (52.3 KiB) Viewed 538 times

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: Select all

otherIsAMonsterTypeCollision:
Add this:

Code: Select all

	;;;;;;;;;;;;;;;;;;;;;;;;;;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: Select all

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 ******************************************

viewtopic.php?f=35&t=1939
User avatar
mouse spirit
Posts: 893
Joined: Tue May 12, 2020 1:13 am
Location: Ohio,North America
Contact:

Re: Moving (bouncing) platform- Ver. 4.1.5

Post by mouse spirit » Sun Aug 09, 2020 2:11 am

This is awesome and i am going to try it out soon.Thank you.
I am game, hear me blip.

WIP my game Almika The Star Rider Densetsu Gaiden
https://www.mediafire.com/file/phef252j ... p.zip/file
Forum link viewtopic.php?f=51&t=5278
weapon121
Posts: 39
Joined: Sat Mar 09, 2019 2:45 pm

Re: Moving (bouncing) platform- Ver. 4.1.5

Post by weapon121 » Sun Aug 09, 2020 2:49 am

mouse spirit wrote:
Sun Aug 09, 2020 2:11 am
This is awesome and i am going to try it out soon.Thank you.
Sure thing ! Hope it comes in handy ;)
WillElm
Posts: 116
Joined: Wed Mar 20, 2019 3:56 am

Re: Moving (bouncing) platform- Ver. 4.1.5

Post by WillElm » Tue Aug 11, 2020 2:39 pm

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
Posts: 39
Joined: Sat Mar 09, 2019 2:45 pm

Re: Moving (bouncing) platform- Ver. 4.1.5

Post by weapon121 » Tue Aug 11, 2020 4:33 pm

WillElm wrote:
Tue Aug 11, 2020 2:39 pm
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!
Post Reply