|
Post by Minilop on May 9, 2022 10:57:06 GMT
|
|
|
Post by Minilop on May 9, 2022 20:35:39 GMT
Thankyou for your tutorials, they are so needed, an excellent , EXCELLENT help guide. Hi, i had an issue with that too, and that above code fixed it for me so thankyou so much. One question. i also noticed, i want able to just from one moving platform to another, only from the wallblock, CAN THIS BE ADJUSTED? for example, if i fall from a great height, i go right through the platform. Here's an updated version of the code that should fix the issue when falling from a great height: EVENT SPRITETYPE1
IF COLLISION 0 ; first check if the player is colliding with the platform, if so:
LET P = Y ; store the Y value of the platform in P
OTHER ; now switch to the player sprite
IF P > Y ; is player above the platform?
SUBTRACT Y FROM P ; if so, by how much?
IF P <= 4 ; if less than 4 px landing is unsuccessful!
ENDSPRITE
EXIT
ELSE
ADD Y TO P ; reset P (the platforms Y co-ord)
LET Y = P ; make the players Y = the platforms Y
SUBTRACT 16 FROM Y ; now put the player on top of the platform
STOPFALL ; and keep the player on top
IF KEY LEFT ; lets add in some controls for movement on the platform
IF CANGOLEFT
SPRITELEFT
ENDIF
ENDIF
IF KEY RIGHT
IF CANGORIGHT
SPRITERIGHT
ENDIF
ENDIF
ENDSPRITE
ENDIF
IF DIRECTION = 0 ; 0 means the platform is moving left but isnt carrying a player
LET DIRECTION = 2 ; so if it was 0 when the player landed use 2 to denote CARRYING LEFT
ELSE ; if not 0 it must be going right
LET DIRECTION = 3 ; so we'll use 3 to denote the platform is CARRYING RIGHT
ENDIF
IF DIRECTION = 2 ; now that the platform is carrying left
IF CANGOLEFT ; check it can still go left
SPRITELEFT ; in which case continue
OTHER ; and set the players Direction to 5 (which we use in the player event)
IF CANGOLEFT
LET DIRECTION = 5
ENDIF
ENDSPRITE ; switch back to the platform
ELSE
LET DIRECTION = 3 ; if platfrom cant go left anymore, switch to carrying right
ENDIF
ENDIF
IF DIRECTION = 3 ; now that the platform is carrying right
IF CANGORIGHT ; check it can still go right
SPRITERIGHT ; in which case continue
OTHER IF CANGORIGHT
LET DIRECTION = 6 ; and set the players Direction to 6 (which we use in the player event)
ENDIF
ENDSPRITE ; switch back to the platform
ELSE LET DIRECTION = 2 ; if platfrom cant go right anymore, switch to carrying left
ENDIF
ENDIF
EXIT
ELSE
ENDSPRITE
ENDIF
ENDIF
; if the player and platform are not colliding any more
IF DIRECTION = 2 ; if it was set to CARRYING LEFT
LET DIRECTION = 0 ; switch to normal left movement (not carrying the player)
ENDIF
IF DIRECTION = 3 ; if it was set to CARRYING RIGHT
LET DIRECTION = 1 ; switch to normal right movement (not carrying the player)
ENDIF
IF DIRECTION = 0 ; normal left movement of the platform (not carrying the player)
IF CANGOLEFT
SPRITELEFT
ELSE
LET DIRECTION = 1
ENDIF
ENDIF
IF DIRECTION = 1 ; normal right movement of the platform (not carrying the player)
IF CANGORIGHT
SPRITERIGHT
ELSE
LET DIRECTION = 0
ENDIF
ENDIF
As for the other request about having multiple platforms and jumping between them, this is entirely possible and there are a number of strategies you could use dependent on how reusable you want them to be, in other words do you think you will have multiple moving platforms on multiple screens, each travelling different distances? its probably a topic for another tutorial!
|
|
|
Post by david911 on May 11, 2022 10:09:53 GMT
Thankyou so much, ill give this a test,. again excellent tutorials.
|
|