Author Topic: Treasure Hunt 3D  (Read 1035 times)

Rick3137

  • Sr. Member
  • ****
  • Posts: 347
  • May the Force be with You
    • View Profile
    • Rick's Programs
Treasure Hunt 3D
« on: September 08, 2016 »
      This is a maze game using the Raycaster library.

      Move through the maze and find the 19 hidden objects.
      Avoid the Guardians.

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Treasure Hunt 3D
« Reply #1 on: September 08, 2016 »
I wish I had a treasure map and GPS!  :)
B+

Marcus

  • Administrator
  • Hero Member
  • *****
  • Posts: 549
    • View Profile
Re: Treasure Hunt 3D
« Reply #2 on: September 19, 2016 »
Yeah, I like maze games, but it was a bit too difficult to find your way around in this one. Could use some sort of progressive map maybe, that builds up while you're exploring the maze.
« Last Edit: September 19, 2016 by Marcus »
.\\\opz

Rick3137

  • Sr. Member
  • ****
  • Posts: 347
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Treasure Hunt 3D
« Reply #3 on: September 21, 2016 »
 You're all right about having a treasure map. I'll try to do better with the next one.

Rick3137

  • Sr. Member
  • ****
  • Posts: 347
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Treasure Hunt 3D
« Reply #4 on: October 24, 2016 »
  Here's the next version, with the treasure map. I hope it makes it beter.

Code: [Select]
import "Raycaster.lib"
import "Keycodes.lib"
import "Speed.lib"
import "ksink.lib"

    '  By Rick3137    http://rb23.yolasite.com/
    '  You have permission to copy, paste, alter or post anywhere as long as you don't copyright my work.
    '  If it breaks your computer or does damage to your health or wealth , I didn't do it.

set window 0, 0, 800, 600, true
set redraw off
visible:
proc RC_InitView 65.0, width(primary), height(primary)
g1=1 ; g2=2 ; g3=3 ; g4=4 ; g5=5 ; g6=6 ; g7=7 ; g1x# ; g2x# ; g3x# ; g4x# ; g5x# ; g6x# ; g7x# ; g1z# ; g2z# ; g3z# ; g4z# ; g5z# ; g6z# ; g7z#
d1 ; d2 ; d3 ; d4 ; d5 ; d6 ; d7 ; score = 0 ; item1 = 0 ; plx ; plz ; Dend = 0 ; Cnt = 0
DrawMap = 0
item[70][70]
flags[][] = RC_LoadMap("assets/m2.txt")
    if sizeof(flags) = 0
 
      set color 255, 255, 255
      set caret 10,10
      write " No map file "
      redraw
      wait keydown
      end
    endif
rem Player setup. Use data from map.
ply?
ply.x# = float(flags[0][RC_X]) + 0.5
ply.z# = float(flags[0][RC_Z]) + 0.5
ply.a# = float(flags[0][RC_ANGLE])
 proc LoadObjects
 proc SetUp
    set color 255, 255, 255
    draw image 21,40,40
    set caret 350,500
    write " Hit Enter Key For Map "
    redraw
    wait keydown
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ MAIN LOOP @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
do
rem Move.
if keydown(VK_LEFT) then ply.a# = ply.a# - 2.0
if keydown(VK_RIGHT) then ply.a# = ply.a# + 2.0
if keydown(VK_UP)
pos#[] = RC_Move(0.4, ply.x#, ply.z#, cos(ply.a#)*0.04, sin(ply.a#)*0.04)
     
   ply.x# = float(pos[RC_X])
   ply.z# = float(pos[RC_Z])
     
endif
if keydown(VK_DOWN)
pos#[] = RC_Move(0.4, ply.x#, ply.z#, -cos(ply.a#)*0.04, -sin(ply.a#)*0.04)
ply.x# = float(pos[RC_X])
ply.z# = float(pos[RC_Z])
endif
   
if keydown(VK_ENTER)  then  DrawMap = 1
if keydown(VK_SPACE)  then  DrawMap = 0
 
set color 10, 20, 40
cls
       if DrawMap = 0 then     
            proc AddObjects 
          proc RC_Render ply.x# , ply.z#, ply.a#, 0.0
            proc PickUp
            proc Print
          redraw
       else
            proc DisplayMap
            redraw
       endif

  if keydown(VK_ESC) then Dend = 1
proc SPD_HoldFrame 60
until Dend = 1
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ End Loop
   draw image 20,40,40

   set caret 200,10
   write " Score = " ; write "  " ; write score

 wln "Press any key to exit ..."
 redraw
 wait keydown

' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ End Program

procedure DisplayMap()
    a = RC_GetMapWidth()
    b = RC_GetMapHeight()
    a = RC_GetWallImage ( 32, 32 )
    c = 0
      set color 50,60,70
    draw rect 0,0,1360,700,1
      set color 0,255,255
     
   for x = 0 to 32
       for y = 0 to 32
            a = RC_GetWallImage (x, y )
            c = item[x][y]
            if a> 0
                   set color 0,255,255
                   draw rect x * 10 + 50, y * 10 + 10, 10, 10, 1
            endif

            if c > 0
              set color 255,0,0
              draw rect x * 10 + 50, y * 10 + 10, 10, 10, 1
            endif
        next
   next
     set color 255,255,0
     set caret 700,20

      set color 0,0,255 ;                                ' Draw Player
      x = int(ply.x#)
      y = int(ply.z#)
   
      draw rect x * 10 + 50, y * 10 + 10, 10, 10, 1



      set color 255,255,255
   do
       x = mousex() ; y = mousey()
       x = x/10 - 4 ; y = y/10
      a=0
      set caret 500,10
      write x; write"   "; write y
      set caret 100,500
         write " Hit Space Bar To Return"
      if keydown(VK_SPACE) then a = 0
   until a = 0
 

endproc


procedure Print()
  set color 255, 255, 255
  if(Cnt > 18 ) then Dend = 1
  set caret 500,10
  write plx ; write "   " ; write plz ; write "       "  ;  write  Cnt 
  set caret 10,10
  write " Score = " ; write "  " ; write score

endproc

procedure SetUp()

 g1x = 8.5 ; g1z = 1.5 ; g2x = 10.5 ; g2z = 1.5 ; g3x = 24.5 ; g3z = 1.5 ; g4x = 7.5 ; g4z = 18.5 ; g5x = 16.5 ; g5z = 18.5 ; g6x = 19.5 ; g6z = 8.5 ; g7x = 18.5 ; g7z = 12.5


   d1 = 1 ; d2 = 1 ; d3 = 1 ; d4 = 1 ; d5 = 1 ; d6 = 1 ; d7 = 1

 proc SetUpObjects

endproc

procedure SetUpObjects()
     item[1][4] = 8 ; item[1][11] = 9  ;  item[8][14] = 10 ; item[4][21] = 11  ;  item[1][30] = 12 
     item[9][30] = 13  ;  item[10][26] = 14 ; item[29][30] = 15  ;  item[26][25] = 16 ; item[30][25] = 17  ;  item[30][21] = 18     
     item[30][18] = 19  ;  item[26][15] = 20 ; item[15][8] = 21  ;  item[15][3] = 22 ; item[19][1] = 23  ;  item[19][4] = 24
     item[30][1] = 25  ;  item[26][7] = 26 ; item[17][16] = 27 
endproc
procedure AddObjects()
      proc RC_ClearObjects
          rem RC_AddObject id,img, x# ,z# , y# , size , -1 , -1
      proc MoveGuards
     
   
    if item[1][4] =  8  then  proc RC_AddObject 8, 3, 1.5, 4.5, 0.0, 0.40, 1, 1
    if item[1][11] =  9  then    proc RC_AddObject 9, 4, 1.5, 11.5, 0.0, 0.40, 1, 1
    if item[8][14] =  10  then    proc RC_AddObject 10, 3, 8.5, 14.5, 0.0, 0.40, 1, 1
    if item[4][21] =  11  then    proc RC_AddObject 11, 4, 4.5, 21.5, 0.0, 0.40, 1, 1
    if item[1][30] =  12  then    proc RC_AddObject 12, 3, 1.5, 30.5, 0.0, 0.40, 1, 1
    if item[9][30] =  13  then    proc RC_AddObject 13, 4, 9.5, 30.5, 0.0, 0.40, 1, 1
    if item[10][26] =  14  then    proc RC_AddObject 14, 5, 10.5, 26.5, 0.0, 0.40, 1, 1
    if item[29][30] =  15  then    proc RC_AddObject 15, 4, 29.5, 30.5, 0.0, 0.40, 1, 1
    if item[26][25] =  16  then    proc RC_AddObject 16, 3, 26.5, 25.5, 0.0, 0.40, 1, 1
    if item[30][25] =  17  then    proc RC_AddObject 17, 5, 30.5, 25.5, 0.0, 0.40, 1, 1
    if item[30][21] =  18  then    proc RC_AddObject 18, 3, 30.5, 21.5, 0.0, 0.40, 1, 1
    if item[30][18] =  19  then    proc RC_AddObject 19, 4, 30.5, 18.5, 0.0, 0.40, 1, 1
    if item[26][15] =  20  then    proc RC_AddObject 20, 5, 26.5, 15.5, 0.0, 0.40, 1, 1
    if item[15][8] =  21  then    proc RC_AddObject 21, 4, 15.5, 8.5, 0.0, 0.40, 1, 1
    if item[15][3] =  22  then    proc RC_AddObject 22, 3, 15.5, 3.5, 0.0, 0.40, 1, 1
    if item[19][1] =  23  then    proc RC_AddObject 23, 5, 19.5, 1.5, 0.0, 0.40, 1, 1
    if item[19][4] =  24  then    proc RC_AddObject 24, 3, 19.5, 4.5, 0.0, 0.40, 1, 1
    if item[30][1] =  25  then    proc RC_AddObject 25, 4, 30.5, 1.5, 0.0, 0.40, 1, 1
    if item[26][7] =  26  then    proc RC_AddObject 26, 3, 26.5, 7.5, 0.0, 0.40, 1, 1
    if item[17][16] =  27  then    proc RC_AddObject 27, 4, 17.5, 16.5, 0.0, 0.40, 1, 1



endproc

procedure MoveGuards()
      gx = 0 ; gz = 0
      if(d1 = 1 ) then g1z = g1z + 0.04
      if(d1 = 0 ) then g1z = g1z - 0.04
      if(g1z > 10.0) then d1 = 0
      if(g1z < 1.5) then d1 = 1
         gz = int(g1z); gx = int(g1x)
      if(gz = plz and gx = plx )
           
           
            ply.x# = 2.0
            ply.z# = 2.0
           proc Snd(9)
            score = score - 1
      endif
      if(d2 = 1 ) then g2z = g2z + 0.06
      if(d2 = 0 ) then g2z = g2z - 0.06
      if(g2z > 17.0) then d2 = 0
      if(g2z < 1.5) then d2 = 1
         gz = int(g2z); gx = int(g2x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9)
            score = score - 2
      endif
      if(d3 = 1 ) then g3z = g3z + 0.04
      if(d3 = 0 ) then g3z = g3z - 0.04
      if(g3z > 16.0) then d3 = 0
      if(g3z < 1.5) then d3 = 1
         gz = int(g3z); gx = int(g3x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9)
            score = score -4
      endif
      if(d4 = 1 ) then g4z = g4z + 0.04
      if(d4 = 0 ) then g4z = g4z - 0.04
      if(g4z > 31.0) then d4 = 0
      if(g4z < 18.0) then d4 = 1
         gz = int(g4z); gx = int(g4x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9)
            score = score - 5
      endif
      if(d5 = 1 ) then g5z = g5z + 0.04
      if(d5 = 0 ) then g5z = g5z - 0.04
      if(g5z > 31.0) then d5 = 0
      if(g5z < 18.0) then d5 = 1
         gz = int(g5z); gx = int(g5x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9)
            score = score - 5
      endif
      if(d6 = 1 ) then g6z = g6z + 0.04
      if(d6 = 0 ) then g6z = g6z - 0.04
      if(g6z > 31.0) then d6 = 0
      if(g6z < 8.0) then d6 = 1
         gz = int(g6z); gx = int(g6x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9) ; score = score - 5

      endif
      if(d7 = 1 ) then g7z = g7z + 0.04
      if(d7 = 0 ) then g7z = g7z - 0.04
      if(g7z > 31.0) then d7 = 0
      if(g7z < 12.0) then d7 = 1
         gz = int(g7z); gx = int(g7x)
      if(gz = plz and gx = plx )
            ply.x# = 2.0
            ply.z# = 2.0
            proc Snd(9) ; score = score - 10

      endif
     
      proc RC_AddObject g1, 1, g1x, g1z, 0.0, 0.40, 1, 1   
      proc RC_AddObject g2, 1, g2x, g2z, 0.0, 0.40, 1, 1
      proc RC_AddObject g3, 1, g3x, g3z, 0.0, 0.40, 1, 1
      proc RC_AddObject g4, 1, g4x, g4z, 0.0, 0.40, 1, 1   
      proc RC_AddObject g5, 1, g5x, g5z, 0.0, 0.40, 1, 1
      proc RC_AddObject g6, 1, g6x, g6z, 0.0, 0.40, 1, 1
      proc RC_AddObject g7, 1, g7x, g7z, 0.0, 0.40, 1, 1

endproc

procedure LoadObjects()
     load image 1, "assets/beholder.bmp"
     load image 2, "assets/M1.png"
     load image 3, "assets/GoldCoins.png"
     load image 4, "assets/SilverCoins.png"
     load image 5, "assets/GoldCoins2.png"
     load image 20, "assets/EndGame.png"
     load image 21, "assets/Start.png"


     set color 255,0,255
     set image colorkey 1, 1
     set image colorkey 2, 1
     set image colorkey 3, 1
     set image colorkey 4, 1
     set image colorkey 5, 1

endproc

procedure PickUp()

plx = int(ply.x#)
plz = int(ply.z#)
   a = item[plx][plz]         
   if a>0
       item1 = a
       item[plx][plz] = 0
       score = score + 10
       Cnt = Cnt + 1
        proc Snd(1)
        redraw
   endif

endproc
  procedure Snd( z)
 if z = 1 then    proc  PlaySound "assets/ding.wav"
 if z = 9 then    proc  PlaySound "assets/laser.wav"

  endproc


end

B+

  • Full Member
  • ***
  • Posts: 215
    • View Profile
Re: Treasure Hunt 3D
« Reply #5 on: October 24, 2016 »
Nice work Rick! I actually got to the gold before the ghoolie got me! Yeah for gold!

The map is definitely a help! :)
B+