WSAD/arrows movement in a labyrinth game?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Shirral
Newbie
Posts: 5
Joined: Tue Dec 27, 2016 3:14 pm
Contact:

WSAD/arrows movement in a labyrinth game?

#1 Post by Shirral »

Hey there! I'm creating a labyrinth game, where the player needs to navigate a labyrinth, find some objects, get to the certain point and use the objects (typical VN story introduction, then the labyrinth part with the places where the objects/traps are linked with VN story flashbacks - character's memories, basically - then, when the labyrinth is solved, typical VN ending again). I want it to look like these oldschool 3D dungeon crawlers, with first person view, drawn pictures of corridors and rooms, and arrows to move to the next possible location (labyrinth grid below) - with turning around instead of just going back so that it's easier to get lost, and it feels like a first-person experience. This part, I know how to do (or at least I think I do) - but I was wondering whether coding WSAD or arrow keys movement would be possible so that the player doesn't have to click on the arrows all the time?

The labyrinth grid (colored tiles being the ones where the objects/traps/other essential interaction points are):

Image

I have found this thread:
viewtopic.php?f=8&t=26511

Which is helpful, but I have 137 tiles in my labyrinth, and with turning instead of taking a step back, which requires a new instance of the same tile (so 1 for the dead ends, 2 for straight/turning corridors, and 3 for the 3-way crossings), there will be a lot of copying and pasting + editing to get all the Jumps right (which I'm already doing with labels and imagebuttons, as I can't think of a better way to do that), so I'm wondering - is there another way? Can you, for example, tie a key to always correspond with an action that is tied to an imagebutton using a specific image? Or use something like Tiled to make a grid of the labyrinth to correspond with the WSAD/arrows keys, but then show your images instead of the tilemap, while also somehow taking care of the turning so that the game takes into consideration not just the fact of moving into a certain tile, but also which other tile you entered the tile from? Sorry for being chaotic here - I'm still a Ren'Py newbie, and I'm clueless here :wink:

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Re: WSAD/arrows movement in a labyrinth game?

#2 Post by nananame »

This kind of thing is quite an extensive project for a newbie (your words).

Also if you know how to do this (the labyrinth) then all you really need is the key, right? Well the absolutely simplest way is to make a screen waiting for input and show it right at the start.

Code: Select all

screen keys():
	    key 'K_UP" action Jump("pressed_up_label")
	    key 'K_DOWN" action Jump("pressed_down_label")
.....
So this will detect your key input. You then do your movement on those labels.
But given what your wrote about jumping and labels and imagebuttons I don't think you're onto a right idea how to do the dungeon crawler... There are many ways of course and I know some have already been discussed on this forum - try the search function.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: WSAD/arrows movement in a labyrinth game?

#3 Post by Imperf3kt »

Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter


Shirral
Newbie
Posts: 5
Joined: Tue Dec 27, 2016 3:14 pm
Contact:

Re: WSAD/arrows movement in a labyrinth game?

#5 Post by Shirral »

Thank you a lot for your answers!
Imperf3kt wrote: Mon Jul 06, 2020 3:20 pm Is this of any use?
viewtopic.php?f=51&t=19245#p249267
Nyaatrap's framework looks great - this is basically how I'd like this to look/work, and someone provided the solution for the key input in the comments. The only problem is, it looks like it's hard to customize - I'd like a lot of my walls to look different from one another, based on the location - ie., I'd like to have pictures on them that can be clicked and interacted with to serve as both storytelling devices and landmarks for the players, objects on the floor in specified places, and tiles where, if the player enters them, the game goes to the typical VN mode, then goes back (this I guess I could look up in the code of one of the games which use it); another thing is, I'd like the game to take a different set of the corridor pictures, and different music, depending on how many collectables the player has collected.
When it comes to these, they work fine with the top-down view, but they don't have the solution for 1st person view, which requires the same tile to be seen from different perspectives, plus most of the problems I described above still applies. I'm sure if I learned a bit of Python, it'd be possible to do it all, but I'm afraid the learning itself will take much more time than manually coding everything with jumps, so I might end up going with nananame's solution in the end, and try to learn once I'm done with this project so that the future ones are made better at least (this one is time sensitive, and I still have to do the writing and graphics).

The only other thing that comes to mind, which would be absolutely amazing, is creating a grid for the labyrinth layout, with "0" or a "-" being a wall and any other number/label name,if that's possible, being "walkable", so that the arrows change the position on the grid and then enable a jump to the label corresponding with a tile number, while the clickable arrows on the screen still operate on jumps alone. However, while I have no idea how to achieve this alone, there's also the case of the first person view = several separate labels for one tile, so the script would also need to account for which direction the player came from. I'm currently naming my labels L1a, L1b, L2b, L2c, L65, L65c, L65d, where the a-d letters correspond to that - so maybe if there was a way to take the tile's number from the grid, add "L" at the beginning, and the right letter at the end?... I imagine that could be extremely complicated, though, so I guess I'll go with jumps for now!

Post Reply

Who is online

Users browsing this forum: No registered users