Moving Platform Objects

dale_coop

Moderator
Staff member
Yes. I use a lot those values too for my “special” game objects that have different behaviors.
 

WolfMerrik

New member
Finally... A Bit more progress

anim_plat.gif



So, After detecting that the entity does indeed have the platformer flag, checked for in playerWasNotHurtDuringCollision:

Code:
	AND #%01000000
	BNE solidMovingPlatform

Then we add this somewhere:

Code:
solidMovingPlatform: ; It is a solid moving platform...

	LDX player1_object
	;LDA ObjectHeight,X
	LDA selfCenterY		; I took this  from the jump on enemy code...
	;ADC #$02		; I am not sure if that is really doing much lol, its still hard to tell
	CMP otherCenterY
	BCS dontJumpOnPlatform
	
	LDA Object_y_hi,y	; This is an attempt to make the player be ON TOP
	STA Object_y_lo,x	; Of the platform object.... it does not work correctly

	LDA Object_status,x
	ORA #%00000100
	STA Object_status,x
	LDA Object_movement,x	
	AND #%00001111
	STA Object_movement,x
	JMP AboveIsSolid	; Go to the collision code for the one way plat...

All of these changes were added to HandleObjectCollisions_Platform_Simple.asm

I have tried adding code to try to make the player move WITH the platform, like so:

Code:
	LDA Object_h_speed_lo,x
	SEC
	ADC Object_h_speed_lo,y
	SEC
	STA Object_h_speed_lo,x

But it has STRANGE results... I do not think I am doing this ANYWHERE near correctly.
Sadly, I have to go to work now, just after having a small breakthrough.

Hopefully though, with a bit more work, and research as to the what the values I am changing actually DO,
This will work as inteded soon!
 

WolfMerrik

New member
I honestly must say,
Being on the BUS on my way to work has given me a lot of ideas on how to get this to work even better!

If I can figure out how to add an objects speed to another (both vert, and horizontal),
This platform script COULD work for 4 directional platforms, which means it could work with lifts as well.

Combine that with a tile that triggers it to change direction, and this could really work great!

Also, setting it so the players bottom is on the top of the object is KEY to this working correctly.
 

WolfMerrik

New member
Convoy_Avenger said:
A lot of great work so far Wolf.

Thanks man!

After just getting home from work, and trying some of the ideas I came up with, I not only got it working, but made a script that lets you jump down from one way platform tiles,
The result is as follows:

platform_working.gif


I am working on commenting it, removing redundant code, and finding a way that I can make this be easily included in others projects!
 

WolfMerrik

New member
dale_coop said:
Congrats WolfMerrik.
Looks great.

Thanks man! It is still VERY buggy, and only really works part of the time, But another day or so, it should be solid! (pun intended)

I also, for the life of me, cannot get ANYTHING, monsters, game objects, etc, to move Up and Down, only Left and Right. Even with ignore gravity. No idea why!
Do you know what might be causing this?

I am assuming it has to do with "ignore gravity", but cant find why
 

dale_coop

Moderator
Staff member
WolfMerrik said:
I also, for the life of me, cannot get ANYTHING, monsters, game objects, etc, to move Up and Down, only Left and Right. Even with ignore gravity. No idea why!
Do you know what might be causing this?
I am assuming it has to do with "ignore gravity", but cant find why

I am not sure... don't think ignore gravity disable vertical movenents. Should be someting else. If I had some time, I would dig in that...
But recently I didn't have time to tests anything (or only a few of the scripts available here on the forum). Busy life.

I think in the platform engine... vertical movements is alowed by :
- jumps
- onladder
I think you could find inspirations with those functionalities (jump scripts... or using onLadder set to #$01 should do the trick :p for up and down. But then you need to find a way to put back to #$00)
 

WolfMerrik

New member
dale_coop said:
- onladder
I think you could find inspirations with those functionalities (jump scripts... or using onLadder set to #$01 should do the trick :p for up and down. But then you need to find a way to put back to #$00)

I looked at that, although I would like to be able to do this for enemies as well. Particularly the "ignore gravity" flag, seems to just ignore vertical movement lol.

For the player, I think I have a workaround, if I can just get the enemy to move up and down lol
 

WolfMerrik

New member
I figuered it out... it does not add to the objects vSpeed with the Acceleration...
So it NEVER changes or goes above 0, except with gravity, or jumping.

I think I may need to rework the entire physics script and make my own.
This will take a bit, but allow for things that I need in my engine, and I can remove things (like ladders) that I do not.
 
Try this, I just figured out a weird way of doing this, kind of... set your monsters details to jump on kills. Then in the jump on monster script in HandleObjectCollisions_Platform_Simple simple comment out the DeactivateCurrentObject like this


Code:
jumpOnMonster:

	LDX player1_object
	;TXA
	;STA tempx
	;JMP playerWasHurtDuringCollision
	;LDX player1_object
	LDA selfCenterY
	CMP otherCenterY
	BCS dontJumpOnMonster
	;;; JUMP ON MONSTER
	LDX player1_object
	LDA #$00
	SEC
	SBC #$04
	STA Object_v_speed_hi,x
	
	LDX tempx
	;DeactivateCurrentObject
	LDY tempy

You bounce around on the moving monster and it does not die, and you do not get hurt. I don't know how, but I'm sure there is way to stop the bouncing, but I cant figure it out.
 

DanielT1985

Member
I see that someone did make moving platforms possible. I was wondering what do I do to import it to my game, and if I do, will it affect any of the other enemies I made in my game, or just the one enemy that is gonna be the platform itself?
 

DanielT1985

Member
WolfMerrik said:
By making a few changes to HandleObjectCollisions_Platform_Simple.asm
I was able to make some SMALL progress lol

platfail.gif


I used Flag 6 for the object, and added this code that handles it:

Code:
solidMovingPlatform: 
	LDX player1_object
	LDA #$00
	SEC
	SBC #$01 ;;basically just push them up 1
	STA Object_v_speed_hi,x
	JMP doneWithThisObjectCollision

To detect the flag, I added this code, right before the code that detects the player being able to jump on the monster flag:
Code:
	AND #%00100000
	BNE solidMovingPlatform

The problem being, you cant jump off of it... I need to find a way to set the players position, and possibly even have the x position of the player move with the block.

It is a start!

I tried adding the code to my asm, and it just gave me this error.

Routines\System\Vectors.asm(1): Value out of range.
 

WillElm

New member
Has anyone had success making a "solid behavior" action step flag out of the jump on code, or using anything shown here? I've been messing with this code and have had all kinds of interesting behaviors, just not what i'm after. You could use what's shown here to make a tractor beam!
 
Top Bottom