[CODE] Renpystein Pseudo 3D with Ray casting

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.
Message
Author
User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

[CODE] Renpystein Pseudo 3D with Ray casting

#1 Post by SusanTheCat » Sun May 20, 2012 1:36 pm

I did this as a proof of concept to see if I could create Castle Wolfenstein 3D effects. It is based on the HTML5 tutorial found here: http://dev.opera.com/articles/view/crea ... l-5-can-1/

YouTube Video of it in action: http://youtu.be/RZZlHbyJcdA

Attached is the code I created. I provide it without guarantee and without much explanation.

Susan


Forgot to add that the source is released under GPLv3 http://www.gnu.org/licenses/gpl-3.0.txt
EDIT: updated code! See new video
http://youtu.be/jw7ThWERj2U
Attachments
Renpystein.zip
(442.98 KiB) Downloaded 289 times
Last edited by SusanTheCat on Sun Aug 19, 2012 3:10 pm, edited 2 times in total.
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
Starshine
Veteran
Posts: 247
Joined: Mon Jan 30, 2012 7:50 am
Completed: http://berry-melon.blogspot.co.uk/2016/ ... -2016.html
Projects: Pancake Surprise (2016)
Tumblr: http://bettybooplover.tumblr.com
Deviantart: berry-melon
Soundcloud: sweepea-1
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#2 Post by Starshine » Sun May 20, 2012 2:01 pm

Things for visual's & concepts and games sure use many scripts and codes. The video version reminds me of a maze game. The concept reminds me of Duke Numen, only without the guns and shooting. I could think of many things that the concept could do, if it works with Ren'py. Isn't Pseudo another word for fake? or mabey it's just the name of the concept.
http://berry-melon.blogspot.com
I'm not resting until I find
What would make your eyes
Glisten like mine
With loves divine!

Boo-Boo I couldn't aspire....to anything...
Higher...than to fill that one desire to make it
My own....Bop-Bop-a-Dop-Boop-Oop-a-Doop honey?

User avatar
Nuxill
Veteran
Posts: 463
Joined: Sat Sep 25, 2010 4:50 pm
Projects: We Are the Hunted, Heart Shard
Tumblr: nuxill
itch: nuxill
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#3 Post by Nuxill » Sun May 20, 2012 2:17 pm

Wow, this is fantastic! I guess one would have to learn a bit about python to be able to use this to it's fullest. Time to hit the books :P

Is it alright to ask how one could make a way to trigger an event when they stepped on a particular part of the map? And how to change the solid colors into images and adding sprites like what's in the second part of the html5 tutorial?

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#4 Post by KimiYoriBaka » Sun May 20, 2012 6:10 pm

this is rather interesting, if somewhat limited in usefulness. You can now use renpy as a shell for an older than old school fps, which is at least progress over the idea of an fps in renpy being merely an amusing joke. That said, while I congratulate you on your success I have to wonder how much of renpy's functions could be used with this other than just the menu screen.

User avatar
Nuxill
Veteran
Posts: 463
Joined: Sat Sep 25, 2010 4:50 pm
Projects: We Are the Hunted, Heart Shard
Tumblr: nuxill
itch: nuxill
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#5 Post by Nuxill » Sun May 20, 2012 6:39 pm

KimiYoriBaka wrote:this is rather interesting, if somewhat limited in usefulness. You can now use renpy as a shell for an older than old school fps, which is at least progress over the idea of an fps in renpy being merely an amusing joke. That said, while I congratulate you on your success I have to wonder how much of renpy's functions could be used with this other than just the menu screen.

Perhaps there would be a way to make the two parts jump between each other? I have no idea if it's possible but if so it could mean the creation of 1st person adventure game with visual novel aspects. Though that would probably need most of the work to be done with pygame instead of renpy.

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#6 Post by SusanTheCat » Sun May 20, 2012 8:46 pm

This was very much me seeing the code for HTML 5 and wondering if I could do it in Ren'py. I also have a version that does the wall textures but it makes my netbook cry.

It is Pseudo 3D because it does not use a 3D rendering engine. It is faking the whole thing. You can't look up or down.

The screen is split into strips and a coloured bar the appropriate size is filled in.

My thought was to use it as a maze. (You wouldn't have to use gaudy colours!) You could set something up in the player's move function to check to see what square you are on and set a flag. The event function would then return with a value.

I will come up with more of a tutorial. I wanted to get the code out into the wild since I don't think I have optimized it too well for Ren'py.

Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
TrickWithAKnife
Eileen-Class Veteran
Posts: 1261
Joined: Fri Mar 16, 2012 11:38 am
Projects: Rika
Organization: Solo (for now)
IRC Nick: Trick
Location: Tokyo, Japan
Contact:

Re: [CODE] Pseudo 3D with Ray casting

#7 Post by TrickWithAKnife » Mon May 21, 2012 6:09 pm

It's a very interesting idea. I have a section in my game where this would be useful, so I'll be watching this topic closely.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.

If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#8 Post by SusanTheCat » Sun Aug 19, 2012 7:54 am

New code! (See first post)



Now with Textures! And punching things!

You are welcome to use the code. It is based on the pythons code Gh0stenstein:
http://code.google.com/p/gh0stenstein/downloads/list
http://www.pygame.org/project-Gh0stenstein+-1882-.html

Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
Nuxill
Veteran
Posts: 463
Joined: Sat Sep 25, 2010 4:50 pm
Projects: We Are the Hunted, Heart Shard
Tumblr: nuxill
itch: nuxill
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#9 Post by Nuxill » Sun Aug 19, 2012 9:22 am

How exciting, I'll have to try it out right away!
I loved the punching sound effects. Did you make those yourself? :lol:

EDIT: How would you go about making it possible for the exit points to jump to different scenes in a story/different labels? Like if instead of just saying 'Test Exit 3', having it so if the player went to exit three a character in the vn part of the game congratulated them.

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#10 Post by SusanTheCat » Sun Aug 19, 2012 9:42 am

Nuxill wrote: How would you go about making it possible for the exit points to jump to different scenes in a story/different labels? Like if instead of just saying 'Test Exit 3', having it so if the player went to exit three a character in the vn part of the game congratulated them.


SusanTheCat wrote:I provide it without guarantee and without much explanation


That said, all you would need is to have an if statement based on the _return variable.

I currently have it set up to return the text from whatever exit you left by,

Code: Select all

        exits = [
            (1.5,1.5,"eileen"),
            (1.5,22.5,"lucy")
        ]


Like

Code: Select all

$ result = _return
if result == "eileen":
    e "You picked me!"

elif result == "lucy":
    e "It looks like you picked Lucy."


Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
Nuxill
Veteran
Posts: 463
Joined: Sat Sep 25, 2010 4:50 pm
Projects: We Are the Hunted, Heart Shard
Tumblr: nuxill
itch: nuxill
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#11 Post by Nuxill » Sun Aug 19, 2012 10:12 am

Ah, I feel so dumb! The answer was so obvious! Thank you. :)

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#12 Post by SusanTheCat » Sun Aug 19, 2012 3:15 pm

The code the new code is derived from is under the GPLv3 Licence.
http://www.gnu.org/licenses/gpl-3.0.txt

And that makes my new code under that licence too.

Susan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas

User avatar
KimiYoriBaka
Miko-Class Veteran
Posts: 636
Joined: Thu May 14, 2009 8:15 pm
Projects: Castle of Arhannia
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#13 Post by KimiYoriBaka » Sun Aug 19, 2012 5:21 pm

what an interesting mix of wolfenstein and doom resources

User avatar
OokamiKasumi
Eileen-Class Veteran
Posts: 1766
Joined: Thu Oct 14, 2010 3:53 am
Completed: 14 games released -- and Counting.
Organization: DarkErotica Games
Deviantart: OokamiKasumi
Location: NC, USA
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#14 Post by OokamiKasumi » Thu May 01, 2014 10:05 am

It doesn't work anymore. :(

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 120, in script
  File "renpy/common/000statements.rpy", line 447, in python
  File "game/script.rpy", line 56, in python
  File "game/renpystein.rpy", line 62, in python
  File "game/renpystein.rpy", line 335, in python
TypeError: range() integer end argument expected, got float.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\execution.py", line 294, in run
    node.execute()
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\ast.py", line 1595, in execute
    self.call("execute")
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\ast.py", line 1613, in call
    renpy.statements.call(method, parsed, *args, **kwargs)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\statements.py", line 144, in call
    return method(parsed, *args, **kwargs)
  File "renpy/common/000statements.rpy", line 447, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\exports.py", line 2095, in call_screen
    rv = renpy.ui.interact(mouse="screen", type="screen", roll_forward=roll_forward)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\ui.py", line 237, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\core.py", line 2059, in interact
    scene_lists.replace_transient()
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\core.py", line 577, in replace_transient
    self.remove(layer, tag)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\core.py", line 851, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\core.py", line 775, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\screen.py", line 189, in _hide
    hid.update()
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\display\screen.py", line 270, in update
    self.screen.function(**self.scope)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\screenlang.py", line 1236, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 56, in <module>
    add Renpystein(600, 400,worldMap,sprite_positions,exits,enemies, 22, 11.5, -1, 0, 0, .66):
  File "game/renpystein.rpy", line 62, in __init__
    self.my_load_image(Image("pics/items/barrel.png"),False),
  File "game/renpystein.rpy", line 335, in my_load_image
    for i in range(width):
  File "L:\Library\!Kenetic Novels\RenPy\renpy-6.15.5-sdk\renpy\python.py", line 558, in revertable_range
    return RevertableList(range(*args))
TypeError: range() integer end argument expected, got float.

Windows-7-6.1.7601-SP1
Ren'Py 6.17.4.409
A Ren'Py Game 0.0

Ookami Kasumi ~ Purveyor of fine Smut.
Most recent Games Completed: For ALL my completed games visit: DarkErotica Games

"No amount of great animation will save a bad story." -- John Lasseter of Pixar

Human Bolt Diary
Regular
Posts: 48
Joined: Fri Oct 11, 2013 12:46 am
Contact:

Re: [CODE] Renpystein Pseudo 3D with Ray casting

#15 Post by Human Bolt Diary » Sat May 03, 2014 3:34 pm

Attached is a fix for that error, plus I've added a "slide" when you're against walls, adapted from the HTML 5 tutorial.
Attachments
Renpystein 5314.zip
(668.43 KiB) Downloaded 121 times

Post Reply

Who is online

Users browsing this forum: No registered users