Devlog 1.0: Ren'Py Movement


Devlog 1.0: Ren'Py Movement

So recently I wanted to add movement into my game. HERE YOU GO


Coding:

Initilization

Youll want to initilaze the variables beforehand, so copy the 1st section of code below. This just prevents any errors.

Screen Buttons

Next, you'll want to add key actions to detect keypresses. Copy the 2nd section of code. What this does, is checks if the image has crossed boundaries. If it hits a bound, it will not be responsive. If it is not on a bound, it will move the image in the direction specified. You may change the boundaries, but I use it specifically in my battle screen. You can also change the keys, to any you like.

Image Addence

Now, just add the image, as shown in the 3rd section of code.  You can change the zoom, as long as the image is not bigger than the screen.

## Initilization ###########################################################################################
default objxpos = 0.8
default objypos = 0.8
## Screen Buttons ##########################################################################################
    key "w" action If(objypos <= 0.6, NullAction(), SetVariable("objypos", objypos - 0.05))
    key "repeat_w" action If(objypos <= 0.6, NullAction(), SetVariable("objypos", objypos - 0.05))
    key "a" action If(objxpos <= 0.4, NullAction(), SetVariable("objxpos", objxpos - 0.02))
    key "repeat_a" action If(objxpos <= 0.4, NullAction(), SetVariable("objxpos", objxpos - 0.02))
    key "s" action If(objypos >= 0.95, NullAction(), SetVariable("objypos", objypos + 0.05))
    key "repeat_s" action If(objypos >= 0.95, NullAction(), SetVariable("objypos", objypos + 0.05))
    key "d" action If(objxpos >= 0.95, NullAction(), SetVariable("objxpos", objxpos + 0.02))
    key "repeat_d" action If(objxpos >= 0.95, NullAction(), SetVariable("objxpos", objxpos + 0.02))
## Image Addence ###########################################################################################
    add "myim.png" xalign objxpos yalign objypos zoom 0.95

Leave a comment

Log in with itch.io to leave a comment.