I look forward to any ideas other people may have.
And yes, I am a programming noob. But I'm slowly getting better, so keep that in mind.
Feel free to do whatever you like with this code. But if you do use it, or parts of it, please let me know.
It would be a big ego boost to know some of my code is in someone else's game.
This is made using launcher version 6.13.9.1702
Current functionality:
- Taking screenshots
- Viewing screenshots (Interface is ugly, but functionality is fine.)
- Scrollable map
- Sound settings in a phone menu affecting the real game
- Self-updating journal/notebook
- Contact information
- Clock (Game time, not real time, although some things may be updated in real time)
- scrollable map with clickable portions
- Calendar with reminders
- Other game options controllable from the phone's menu.
- Web browser (Just some simplified dummy sites that hyperlink to real websites using the player's browser)
0.rpy:
This is not complete. There are mountains of variables for the language study part, but I want to keep that part private.
I will add a few words later as examples though.
Code: Select all
#******************************************************************#
# VARIABLES #
#******************************************************************#
# For setting up the variables before they need to be used. There will be a lot. #
init: #
$ photos = [] # Used for the camera
$ persistent.sv = 0
$ currently_viewed_picture = 0 # This is used in the picture viewing app, to keep track of which photo is being viewed.
I will share the notebook/journal code later. I want to remove some parts of it first, as the purpose of this is to share functionality, not game contents.
Code: Select all
# This creates the button to show the phone menus
screen button:
vbox xalign 0.0 yalign 0.0:
imagebutton:
idle "Phone/phone smallest.png"
hover "Phone/phone smaller.png"
action ui.callsinnewcontext("mainphonescreen") # FOR TESTING OTHER PHONE ICONS
label hide_all_phone_screens: # It's a little tidier to do it this way.
hide screen blank_phone_screen
hide screen mainphonescreen
hide screen show_bigass_sideways_phone
hide screen show_the_actual_photos
hide screen start_map_app
hide screen start_map_travel_app
hide screen start_sound_options
hide screen view_photos
hide screen viewport_alphabetical
hide screen viewport_category
hide screen viewport_category_or_alphabetical
hide screen travel_map_a
hide screen travel_map_b
hide screen travel_map_c
return
#*******************************************************************************#
# PHONE STARTING SCREEN #
#*******************************************************************************#
label mainphonescreen:
call hide_all_phone_screens
show screen mainphonescreen
"" # Need this to function properly.
jump mainphonescreen #Keeps the menu there if the player clicks another part of the screen
return
# This part shows the main phone screen, and controls what happens when icons are clicked.
screen mainphonescreen:
imagemap:
ground "Phone/300x400 phone with icons.png"
hover "Phone/300x400 phone with glowing icons.png"
hotspot (22, 100, 68, 68) clicked ui.jumps("take_a_photo") # 1st icon (Camera)
#hotspot (93, 115, 50, 50) clicked ui.jumps("mainphonescreen") # 2nd icon (Safari)
#hotspot (149, 115, 50, 50) clicked ui.jumps("mainphonescreen") # 3rd icon (Calendar)
#hotspot (204, 115, 50, 50) clicked ui.jumps("mainphonescreen") # 4th icon (Clock)
#hotspot (38, 188, 50, 50) clicked ui.jumps("mainphonescreen") # 5th icon (Japanese study app)
#hotspot (93, 188, 50, 50) clicked ui.jumps("mainphonescreen") # 6th icon (Mail)
hotspot (176, 190, 68, 68) clicked ui.jumps("start_map") # 7th icon (Map)
#hotspot (204, 188, 50, 50) clicked ui.jumps("mainphonescreen") # 8th icon (Phone)
if persistent.sv > 0: # So it doesn't display photos that aren't there.
hotspot (23, 281, 68, 68) clicked ui.jumps("view_photos") # 9th icon (Pictures)
#hotspot (93, 260, 50, 50) clicked ui.jumps("mainphonescreen") # 10th icon (Settings)
#hotspot (149, 260, 50, 50) clicked ui.jumps("mainphonescreen") # 11th icon (Contacts)
#hotspot (249, 271, 68, 68) clicked ui.jumps("start_travel_map") # 12th icon (Train timetable?)
hotspot (249, 271, 68, 68) clicked ui.jumps("travel_map_a") # 12th icon (Train timetable?)
#hotspot (38, 334, 50, 50) clicked ui.jumps("mainphonescreen") # 13th icon (Messages)
hotspot (97, 364, 68, 68) clicked ui.jumps("start_sound_options") # 14th icon (Music)
#hotspot (179, 369, 68, 68) clicked ui.jumps("start_word_list") # 15th icon (Notebook)
#The notebook IS working. I've disabled it for now, but I may show it later.
hotspot (127, 492, 86, 42) clicked ui.jumps("hide_all_phone_screens") # Home button (Exits)
screen blank_phone_screen:
imagemap:
ground "Phone/300x400 phone no icons.png"
hover "Phone/300x400 phone no icons.png"
hotspot (127, 492, 86, 42) clicked ui.jumps("mainphonescreen")
#*******************************************************************************#
# NOTEBOOK FUNCTIONALITY #
#*******************************************************************************#
label sort_alphabetically:
call hide_all_phone_screens
show screen viewport_alphabetical
"Wow, that's a lot of letters."
jump sort_alphabetically
return
label sort_by_category:
call hide_all_phone_screens
show screen viewport_category
"Sorting alphabetically..."
return
label temp:
"Nothing really happens here. Just a temp screen"
return
#**********************************************#
# This part is for the volume/sound controls on the phone #
#**********************************************#
label start_sound_options:
call hide_all_phone_screens
show screen blank_phone_screen
show screen start_sound_options
"Showing sound options..." # Need this to function properly.
jump start_sound_options #Keeps the menu there if the player clicks another part of the screen
return
screen start_sound_options:
side "c b r":
area (28, 107, 284, 342)
viewport id "vp":
draggable True
vbox:
frame:
style_group "pref"
has vbox
label _("Music Volume")
bar value Preference("music volume")
#The next lines are for testing music volume. Change the track name to whatever you will use.
#textbutton "1":
# action Play("music", "Music/Tristam - I'm Going Down (DotEXE Remix).mp3")
# style "soundtest_button"
#textbutton "2":
# action Play("music", "Music/DotEXE - 38 Degrees.mp3")
# style "soundtest_button"
frame:
style_group "pref"
has vbox
label _("Sound Volume")
bar value Preference("sound volume")
if config.sample_sound:
textbutton "Test":
action Play("sound", config.sample_sound)
style "soundtest_button"
frame:
style_group "pref"
has vbox
label _("Voice Volume")
bar value Preference("voice volume")
if config.sample_voice:
textbutton "Test":
action Play("voice", config.sample_voice)
style "soundtest_button"
bar value XScrollValue("vp")
vbar value YScrollValue("vp")
#*******************************************************************************#
# MAP OF TOKYO #
#*******************************************************************************#
# I'm planning to add the ability to zoom in and out of the map.
label start_map:
call hide_all_phone_screens
show screen blank_phone_screen
show screen start_map_app
"Now I can scroll around to see Tokyo" # Need this to function properly.
jump start_map#Keeps the menu there if the player clicks another part of the screen
return
screen start_map_app:
side "c b r":
area (22, 103, 296, 353)
viewport id "vp":
draggable True
vbox:
imagebutton:
idle "Maps/mega tokyo map 3.jpg"
hover "Maps/mega tokyo map 3.jpg"
#action ui.callsinnewcontext("start_word_list") # FOR TESTING OTHER PHONE ICONS
bar value XScrollValue("vp")
vbar value YScrollValue("vp")
#*******************************************************************************#
# MAP FOR TRAVELLING AROUND TOKYO #
#*******************************************************************************#
label travel_map_a:
call hide_all_phone_screens
show screen blank_phone_screen
show screen travel_map_a
"" #Need this, or bad things will happen...
jump travel_map_a # To prevent more bad things happening.
label travel_map_b:
call hide_all_phone_screens
show screen blank_phone_screen
show screen travel_map_b
"" #Need this, or bad things will happen...
jump travel_map_b # To prevent more bad things happening.
label travel_map_c:
call hide_all_phone_screens
show screen blank_phone_screen
show screen travel_map_c
"" #Need this, or bad things will happen...
jump travel_map_c # To prevent more bad things happening.
screen travel_map_a:
side "c b r":
area (22, 103, 296, 353)
viewport id "vp":
vbox:
imagemap:
ground "Maps/Travel map/a.png"
hover "Maps/Travel map/a2.png"
hotspot (172, 73, 49, 14) clicked ui.jumps("mainphonescreen") # Ikebukuro
hotspot (193, 150, 49, 11) clicked ui.jumps("mainphonescreen") # Kabukicho
hotspot (190, 162, 43, 12) clicked ui.jumps("mainphonescreen") # Shinjuku
hotspot (247, 143, 48, 76) clicked ui.jumps("travel_map_b") # Next screen
screen travel_map_b:
side "c b r":
area (22, 103, 296, 353)
viewport id "vp":
vbox:
imagemap:
ground "Maps/Travel map/b.png"
hover "Maps/Travel map/b2.png"
hotspot (40, 75, 48, 11) clicked ui.jumps("mainphonescreen") # Ikebukuro
hotspot (61, 150, 51, 11) clicked ui.jumps("mainphonescreen") # Kabukicho
hotspot (39, 212, 40, 12) clicked ui.jumps("mainphonescreen") # Harajuku
#hotspot (0, 0, 0, 0) clicked ui.jumps("mainphonescreen") # Will add more areas
hotspot (0, 143, 38, 76) clicked ui.jumps("travel_map_a") # Previous screen
hotspot (247, 143, 48, 78) clicked ui.jumps("travel_map_c") # Next screen
screen travel_map_c:
side "c b r":
area (22, 103, 296, 353)
viewport id "vp":
vbox:
imagemap:
ground "Maps/Travel map/c.png"
hover "Maps/Travel map/c2.png"
hotspot (241, 221, 53, 48) clicked ui.jumps("mainphonescreen") # Narita airport
hotspot (208, 288, 45, 24) clicked ui.jumps("mainphonescreen") # Disneyland
#hotspot (0, 0, 0, 0) clicked ui.jumps("mainphonescreen") # Will add more areas
hotspot (0, 143, 48, 76) clicked ui.jumps("travel_map_b") # Previous screen
#**********************************************#
# This is the setup for taking photos #
#**********************************************#
# It's including the phone in the photos. Need to fix that. #
init:
python:
import os
def camera_take_photo():
newPhoto = renpy.invoke_in_new_context (_camera_take_photo)
renpy.transition(Fade(0,0,0.5,color=(255,255,255,255)))
photos.append(newPhoto)
return "photo_taken"
def _camera_take_photo():
renpy.pause(0.0)
renpy.take_screenshot((960,540)) # 75% of screen size
#renpy.take_screenshot((640,360)) # 50% of screen size
#renpy.take_screenshot((1280,720)) # Full screen
#renpy.take_screenshot((677,380)) # Resized to fit the phone screen
photo = renpy.game.interface.get_screenshot()
photoname = str(persistent.sv)
photodir = config.basedir + "/game/pho/"
if(os.path.isdir(photodir) == False):
os.mkdir(photodir)
f = open(photodir + photoname + ".png", "wb")
f.write(photo)
f.close()
return photoname
#**********************************************#
# This part is for taking photos on the phone #
#**********************************************#
# It's still taking photos of the camera. Need to fix that. #
# Also need how to recall the image names for display. #
label take_a_photo:
call hide_all_phone_screens
$ camera_take_photo()
$ renpy.pause(0.3)
"Photo taken." # Need something here to function properly.
call assign_next_photo_number
jump mainphonescreen
return
label assign_next_photo_number:
$ persistent.sv += 1
return
#***********************************************#
# This part is for viewing photos on the phone #
#***********************************************#
label view_photos:
$ currently_viewed_picture = 1
jump view_photos_2
#label show_the_actual_photos:
label view_photos_2: # Split into 2 parts to make changing image easier.
call hide_all_phone_screens
show screen view_photos
show screen show_the_actual_photos
""
jump view_photos_2
return
screen view_photos:
imagemap:
ground "Phone/phoneforpictureviewing.png"
hover "Phone/phoneforpictureviewingblurry.png"
hotspot (182, 420, 238, 73) clicked ui.jumps("view_previous_photo") # Left button
hotspot (618, 420, 238, 73) clicked ui.jumps("view_next_photo") # Right button
hotspot (861, 218, 107, 102) clicked ui.jumps("mainphonescreen") # Home button
screen show_the_actual_photos:
side "c b r":
area (180, 38, 689, 383)
viewport id "vp":
draggable True
vbox:
for i in range(currently_viewed_picture):
imagebutton:
idle ("pho/%d.png" % i)
hover ("pho/%d.png" % i)
bar value XScrollValue("vp")
vbar value YScrollValue("vp")
label view_previous_photo:
if currently_viewed_picture == 1:
"This must be the first photo." # Just so the photo doesn't change
if currently_viewed_picture > 1:
$ currently_viewed_picture -= 1
jump view_photos_2
return
label view_next_photo:
if currently_viewed_picture < persistent.sv:
$ currently_viewed_picture += 1
""
if currently_viewed_picture == persistent.sv:
"I guess this is the last photo." # Just so the photo doesn't change
jump view_photos_2
return
If you want to change the window size, modify the appropriate line in options.rpy to:
Code: Select all
config.screen_width = 1280
config.screen_height = 720
Code: Select all
init:
python:
style.button_text.size = 18
Code: Select all
show screen button