Author Topic: Raycasting  (Read 704 times)

johnno56

  • Guest
Raycasting
« on: August 10, 2014 »
Since the new Naalaa update, my Raycaster Editor, now displays the correct colours. YES!

My question is:  Is there a tutorial, or a step-by-step procedure, that demonstrates how to integrate the RC data into a potential game? I think I have figured out how to use the editor. But just navigating through ones creation, from within the editor, does not really make it a game. Am I making any sense? Hmmm. How about: It's pointless creating a map if you don't use it while you are driving. Or something like that...

Any ideas?

J

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 541
    • View Profile
Re: Raycasting
« Reply #1 on: August 10, 2014 »
Have a look at the examples in ned's example browser, the examples there are pretty step-by-step:ish. Or you could follow the wonderful video tutorial (I's just a little drunk while making it): https://www.youtube.com/watch?v=i5UgH_eB2jE (only useful if you can view it in HD, as there's coding involved.)
.\\\opz

johnno56

  • Guest
Re: Raycasting
« Reply #2 on: August 10, 2014 »
Will do for checking out the examples. I spotted the video a short while ago and passed it by because there were no spoken instructions. I am now in the process of downloading it. The music, as you say, repeats a few times. Almost hypnotic. I will watch it in HD and silence the music. LOL

Many thanks for the help.

J

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 541
    • View Profile
Re: Raycasting
« Reply #3 on: August 10, 2014 »
I spotted the video a short while ago and passed it by because there were no spoken instructions.

Spoken instructions? I'd be banned from YouTube because of my Swedish accent. Or, wait a tick, Swedish PewDiePie is still there, isn't he?

(Checking ...)

Yes, he's still there, and he's got the most subscribers in the whole world. I'll ask YouTube to close his channel because of the accent.

Edit  Actually I like PewDiePie. My eleven year old does nothing but watch gamers on Youtube, and I guess I've been infected. Prefer AVGN, Pat the NES Punk and JonTron though. But no time for that now, just programmed the elevators for robowack and they turned out well, so now I've got to put elevators all over the place so that everyone gets happy.
« Last Edit: August 10, 2014 by Marcus »
.\\\opz

johnno56

  • Guest
Re: Raycasting
« Reply #4 on: August 10, 2014 »
Accent or not, the video was very clear, and easy to follow. (did I mention before that I like 'easy'?)

I have a slight problem. I think it might be because I run Naalaa through 'Wine' on my Linux machine. I will include the code that I cut-and-paste from the editor. I will also include the error.

Code: [Select]
rem import the libraries we need
import "Raycaster.lib"
import "Keycodes.lib"
import "Speed.lib"

rem Some variables for player position and direction.
playerX# = 1.5
playerZ# = 1.5
playerAngle# = 45.0

rem Setup window. Let's use a lores 320x240 view scaled to 640x480.
set window 32, 32, 320, 240, false, 2

rem Turn on double buffering.
set redraw off

rem Load the map we just created in the editor. Just forget about the
rem loader flags for now :)
flags[][] = RC_LoadMap("map/1.txt")

rem Init the Raycaster view. The first parameter is the Field Of View
rem (fov). The second and third are the width and height of the display
rem area (Let's use the full window).
proc RC_InitView 60.0, 320, 240

rem Loop until player preses ESC
do

rem Let's code the controls :)

rem Turn left when the player presses the left arrow key
if keydown(VK_LEFT)
rem Rotate by changing the angle
playerAngle = playerAngle - 4.0
endif
rem Turn right when the player presses the right arrow key
if keydown(VK_RIGHT)
rem Rotate by changing the angle
playerAngle = playerAngle + 4.0
endif

rem Let the Raycaster do its thing.
proc RC_Render playerX, playerZ, playerAngle           <====  Line 43

rem Update window graphics and use the Speed.lib to maintain constant fps.
redraw
proc SPD_HoldFrame 60
until keydown(VK_ESC, true)

================================

Output:
=== Compile using naalaa6.exe ===
Compiling Z:\home\john\naalaa6\me\rctest\game.txt ...
ERROR on line 43:
  Expected ',', got '

I have retyped the line over and over again to rule out a 'typo'. I checked it with the video and it appears to be the same. (in the video, the game was tested, just after completing this line of code. The video version (after the buffering error was corrected) ran fine. My version did not.

I tested the game again, with line 43 commented out, and re-ran. I expected a black window and that is what I got. Un-commented line 43 and the program terminated with the above error. I concluded that line 43 IS the cause of the error. I also concluded that, because the line 43 that I typed is exactly the same as the line of code on the video, that the error is an OS caused error.

Can you please check the code listing and test it for me? If it runs fine on your machine then that will confirm that MY machine is the cause.

Much appreciated.

J

ps: Also used a text editor and cut and paste into Naalaa editor (just to rule out an editor problem) and produced the same error *cry*
« Last Edit: August 10, 2014 by johnno56 »

johnno56

  • Guest
Re: Raycasting
« Reply #5 on: August 10, 2014 »
Applied the ",0.0" and the error no longer appears.

I have noticed that the editor seems to be allergic to bmp files that are NOT 24bit... (this is not a drama as I prefer using png's) I have also tested the editor with png's and bmp's (both plain colour and textured) and the editor handled them quite well.

Many thanks for the assist. Much appreciated.

J

johnno56

  • Guest
Re: Raycasting
« Reply #6 on: August 11, 2014 »
Completed your video tutorial and all went well. I have a minor display issue, but that is part of the problem of running Windows based applications via an emulator, on Linux.

I found one small problem with your video.... It finished and left me wanting more... *sigh*

Well done. Excellent job.

J