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!
It works great verticaly also!
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.
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.
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:
Add this:
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:
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
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!
It works great verticaly also!
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.
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.
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