Simple Navigation System

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
demonangelz
Regular
Posts: 51
Joined: Tue Aug 23, 2011 10:19 am
Contact:

Simple Navigation System

#1 Post by demonangelz »

Quick Edit: If you have any questions, comment, etc, please feel free to post in this forum or pm me! I am occasionally busy but I will try my best to answer ASAP!
Edit 2: Added more information. Sorry about that, PyTom! I was in a hurry when I first posted this :mrgreen: I added a small tutorial below on how to use this code, hope it helps and any more questions or concerns, please feel free to ask! Apologies for the small images...I'm not sure how I can upload them and also place them in their original size :?

Hey guys, I was just messing around for a game I'm making (very early stages haha...) and decided to share this with you guys.
It's basically a simple navigation system/pick locations and places to go.

First, the download link (and basic tutorial below)
https://www.dropbox.com/s/mm3kmvlu3fn4p ... m.zip?dl=0

The code is free to use, modify and etc. Do whatever you want with it, Credit is preferred but not required if you do use the code.
Here's a screenshot on how the map looks. You can change the backgrounds, icons, etc, etc, this is only an example.
Ignore the description and stuff that was just taken from my game >_<
Capture-ss1.PNG
You can have as few as 1 location and as many as 10 locations total XP. They light up when you hover over them, start the demo and you'll see what I mean.
And these screenshots are from my own game so they're not included in the demo but it's the same type of logic being applied:
Capture10.PNG
Capture9.PNG
My code itself gives an example of how you would go about creating such a system so if you prefer a different set up and placement of the icons, you can always get more creative and try to write your own navigation picker/system/whatever. XD

The icons are called the Legendora Icon Set by Raindropmemory on Devianart.
The backgrounds are from http://may.force.mepage.jp/
The textbox design, background design on the map page and text history is all done by me. Feel free to reference them, use them as a framework for your own designs but I would prefer if you don't use the material themselves. ^^

Basic Tutorial on How To Use The Code

Define Your Locations

So first of all, there's the maps.rpy where you define all your locations:
Capture1.PNG
This must be called in the beginning of your game. Inside my script.rpy, I call this first before I do anything else. It initializes all the locations you will be using for your map.
You don't need to follow the naming convention I have for each variable (example: location_impatieus_classroom, etc).

The Location() method takes two parameters, the first is the name of this location which will be returned later (more details below on this) and your icon name, this is important since there's a specific naming convention I use here.
See this folder:
Capture6.PNG
My icon is named "classroom" and "classroom_select" and the first parameter therefore will be "classroom". The code assumes that it will be a PNG file so save it as one XD.
The hovered icon must be named the same as your original icon followed by a '_select' at the end. Another example, I have my normal icon as "hallway" so the hover icon must be "hallway_select". They are both located within maps/Impatieus folder.
So I will initialize that location as Location("hallway","Impatieus")

The second is the sub-folder where you're keeping your png icons. The default folder is 'maps' and inside that I have a folder named 'Impatieus' which contains all my icons.
You don't have to organize it like I do, it was just my own preference when I wrote the code. ^^

Map Instances (defining your locations to be used in each map)
In the map_instances.rpy, you will see this code:
Capture2.PNG
listLocations.addLocation() takes in the location variables you defined in the previous step.
What this is doing is basically placing all the icons of the places you want to go on the screen.
For example, I could have put only the hallway and classroom as the specific locations I want the player to be able to go to.

I defined it so that the icons will be placed in this following order -> top left corner, top right corner, next spot left side, next spot right side. If that's confusing, this is what I mean:
Capture3.PNG
In this map example, the hallway is the first location I added, grand hall is the second, classroom is the third and quest is the fourth. Hopefully that makes sense on how the pattern works?
In total, I can have 10 locations with this kind of placement.

The location_impatieus_bg is my own background which you can use as a general base for making your own backgrounds since the current code follows this specific way of placing icons or....
If you prefer a different way of placing the location icons, feel free to modify it as you see fit.
To edit the way icons are placed, in maps.rpy, I have this method which is defining how the icons are placed. This would be what you want to modify.
Capture5.PNG
Capture5.PNG (11.3 KiB) Viewed 6448 times
So notice in this same screenshot, there is a go_to variable that gets set to equal the return value when I call location_screen. This go_to variable is the first parameter of Location() from the previous step.
Capture2.PNG
So I defined classroom as one of the locations. go_to will return the string "classroom" from the way I defined it as Location("classroom","Impatieus"). (same screenshot XP)
Capture1.PNG


In this case, I check what go_to equals and then direct the player to different labels depending on that value. I use call because I want the player to return to the map afterwards. If you don't want the player to return to that map, use jump instead to that label.
There's a target_area boolean I use because I want the story to continue once the player clicks on that. This means I don't want them to return to this map after they go to the quest room for this example.
The listLocations.clearList() method has to be called to 'clean up' afterwards. If you change locations for the next time you use the map, you wouldn't want the old ones to stick around.

Putting everything in the game
Now putting this all together into the game. First, to show the screen, you will call the label. Whether that's with call or jump, it's really your own preference.
Capture7.PNG
Capture7.PNG (10.79 KiB) Viewed 4379 times
So after that, you would be direct to the navigation screen where you click on where to go.

The continue_story label I have is what I jump to at the end when the player chooses the quest room and break out of the while loop since target_area = true when they click on quest_room.
And that basically continues your story to do whatever.

Misc
This is basically a description spot of the entire city/school/etc if you want to give the reader a general overview ^^
Capture4.PNG
Note: the demo might say the max locations is 8 in the comments, that should be corrected to 10
Last edited by demonangelz on Mon Jul 27, 2015 10:04 pm, edited 2 times in total.
I have returned after a long time away. Working on a small project, hope I'll be able to show it on here soon! =D

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Simple Navigation System

#2 Post by PyTom »

Could you post some examples, or maybe a tutorial of some sort? Being able to see what it takes to define a new place might help people evaluate this framework.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

demonangelz
Regular
Posts: 51
Joined: Tue Aug 23, 2011 10:19 am
Contact:

Re: Simple Navigation System

#3 Post by demonangelz »

Posted a tutorial, hope that helps! I'll also attach a few examples of how I used it in my own game since that might also help people see how it works >__<
I have returned after a long time away. Working on a small project, hope I'll be able to show it on here soon! =D

Post Reply

Who is online

Users browsing this forum: No registered users