color map [update 2020-04-24]

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
User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

color map [update 2020-04-24]

#1 Post by Per K Grok »



Using a color map loaded to a surface to mark up areas on the game screen.

EDIT 2020-04-24:
It has been brought to my attention that there is a problem with using this code when attempting to make a save.

I have made the following changes in the original code to correct that problem. The main part is to move the im.load_surface part to a function. This way there is no loaded surface for save to handle

Code: Select all

init python:
    def colorpick(pix,x,y):
        if pix==1:
            floor=im.load_surface("images/colormap.png")
        inout=floor.get_at((x,y)) [:3]
        return inout
The variable pix makes it possible to use the function for more than one colormap, though only one is necessary in this example

In the code below the following chances are needed.

remove
$ floor=im.load_surface("images/colormap.png")

and replace
$ inout=floor.get_at((mX,mY)) [:3]
with
$ inout=colorpick(1,mX,mY)


and you should be good to go.


original code

Code: Select all

screen checker():

    text str(mX) + ":" + str(mY)
    text str(inout) ypos 20
    text teller pos (mX, mY-20) color "#F00"

label start:

label room:
    scene room
    show screen checker
    $ floor=im.load_surface("images/colormap.png")

label rotator:
    $ mX, mY = renpy.get_mouse_pos()
    $ inout=floor.get_at((mX,mY)) [:3]

    if inout==(255,255,255):
        $ teller="Nothing worth noting."
    elif inout==(255,0,0):
        $ teller="Door"
    elif inout==(255,0,128):
        $ teller="Lamp"
    elif inout==(255,32,0):
        $ teller="Anzi the Owl"
    elif inout==(255,64,0):
        $ teller="Semi's head"
    elif inout==(255,96,0):
        $ teller="Semi"
    elif inout==(255,128,0):
        $ teller="Stool"
    elif inout==(0, 255,64):
        $ teller="Table"
    elif inout==(0, 0, 255):
        $ teller="Game of Ur"
    elif inout==(255,0,0):
        $ teller="Bob"
    elif inout==(0,255,0):
        $ teller="Bob's hat"
    elif inout==(96, 255,0):
        $ teller="Bob's face"
    elif inout==(128, 255,0):
        $ teller="Bob's beard"
    elif inout==(0,255,128):
        $ teller="Bob"
    elif inout==(64,255,0):
        $ teller="Bob's hand"
    elif inout==(32,255,0):
        $ teller="Bob's sword"
    elif inout==(0,255,96):
        $ teller="Pillow"
    elif inout==(255,0,96):
        $ teller="Exit"
    elif inout==(64,0,255):
        $ teller="Sign"
    elif inout==(128,0,255):
        $ teller="X"
    elif inout==(96,0,255):
        $ teller="flower"

    $ renpy.pause(0.1, hard="True")
    jump rotator
Last edited by Per K Grok on Fri Apr 24, 2020 2:08 pm, edited 2 times in total.

Mutive
Veteran
Posts: 344
Joined: Tue Nov 21, 2017 2:23 am
Completed: Eidolon, Minion!, Love Furever, Epilogue
Contact:

Re: color map

#2 Post by Mutive »

Oooh, this is a nice simple example which I may end up using if I ever work on a point and click game. :) Thanks for posting!
Enjoy Eidolon, my free to play game at: https://mutive.itch.io/eidolon, Minion! at: https://mutive.itch.io/minion or Epilogue at: https://mutive.itch.io/epilogue

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: color map

#3 Post by Per K Grok »

Mutive wrote: Thu Nov 07, 2019 12:35 pm Oooh, this is a nice simple example which I may end up using if I ever work on a point and click game. :) Thanks for posting!
Thanks. I appreciate your comment. :)

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: color map [update 2020-04-24]

#4 Post by Per K Grok »

update in OP :)

Post Reply

Who is online

Users browsing this forum: No registered users