My code:
map_planet.rpy
Code: Select all
init python:
# Initialize variables
star_systems = {
'tatooine': {
'name': 'Tatooine',
'x': 300,
'y': 400,
'description': 'A desert planet on the Outer Rim Territories.',
'image': 'images/tatooine.png',
},
'alderaan': {
'name': 'Alderaan',
'x': 700,
'y': 200,
'description': 'A peaceful planet in the Core Worlds, destroyed by the Death Star.',
'image': 'images/alderaan.png',
},
# Add more star systems here
}
# Function to display star system information
def display_system_info(system):
renpy.show('system_info')
renpy.system_name.text = system['name']
renpy.system_description.text = system['description']
renpy.system_image.image = system['image']
# Load the click sound effect
config.sound_volume = 0.5 # Adjust the volume as needed
renpy.sound.load('click.ogg')
# Function to handle mouse-based navigation
def star_map_scroll(ev):
map_background = renpy.gui.interactables['map_background']
x, y = ev.x - gui.center_x, ev.y - gui.center_y
if ev.type == 'axismove' and ev.axis == 'mouse_scroll':
scroll_amount = ev.value * 0.1
map_background.xpos += scroll_amount * x
map_background.ypos += scroll_amount * y
elif ev.type == 'button_release' and ev.button == 1: # Middle mouse button
map_background.xpos -= x * 0.1
map_background.ypos -= y * 0.1
def display_system_info(system):
renpy.show('system_info')
renpy.system_name.text = system['name']
renpy.system_description.text = system['description']
renpy.system_image.image = system['image']
if system['name'] == 'Tatooine':
renpy.jump('tatooine_events')
elif system['name'] == 'Alderaan':
renpy.jump('alderaan_events')
# Add more star systems here
Code: Select all
label tatooine_events:
# Event code for Tatooine
label alderaan_events:
# Event code for Alderaan
Code: Select all
screen star_map:
tag menu
vbox:
text "Star Wars Galaxy Map"
scene:
# Replace 'background.png' with your own background image
image "background.png" id "map_background"
# Add star systems
for system in star_systems.values():
imagebutton:
xalign 0.5 yalign 0.5
xpos system['x'] ypos system['y']
idle system['image']
action [Function(display_system_info, system), Play('click.ogg')]
# Add trade routes (example)
# image "images/trade_route.png" xpos 300 ypos 400 zorder 1
# Add mouse-based navigation
imagebutton:
idle "transparent.png" # Use a transparent image for the hitbox
xfill True yfill True
action Function(star_map_scroll, ev)
window hide vbox:
text "System Information"
text "[system_name]"
text "[system_description]"
textbutton "Close" action Return()
window system_info:
has vbox
text "[system_name]" style 'bold'
text "[system_description]"
textbutton "Close" action Hide('system_info')
1) I can't seem to make a zoom in and zoom out button for the map, and it makes it very difficult to navigate the current map.
2) (Optional) create a search by name, for quick orientation by object.
3) (Optional) how to spell out in function(def) increase by 0.2, manually writing for each planet is a pain,
4) How to facilitate the labor translator to another language, info about each planet, of course you can completely copy the entire rpy file in the folder tl, but he is bound to somewhere that entering the translated information.