Author Topic: Yabasic Rocks !!!  (Read 22801 times)

0 Members and 1 Guest are viewing this topic.

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: Yabasic Rocks !!!
« Reply #20 on: January 11, 2007 »
Nice program!
It's like the other Raycaster Engine made at the old Ezboard Forums. That one was great: cell shaded walls and ran really fast!
The only problem with your one is the speed, no offence, but the other Raycaster engine ran really smooth, sometimes abit too fast. Maybe if you tried to change some sequences to cut out some slow down? You could look at the other engine's code below to see if you could change something.
::This was coded by laurenz
I changed a few things:
  Before, you could not move with to buttons pressed.
             I modified this using
Code: [Select]
if and(j,num)<>0 turn=turn+1  Before, the map was behind the shaded walls, making it invisible when you went close to the walls.
             I modified this by moving the map code after the wall drwaing code.
  I added a slowdown option, located as SLOWDOWN=0. Increase this value to slow the program's frame reat down.
NB/ The program uses Binary for the map data. Jim told me this when i asked how to change the map.
Put the value into your computers calculator and set it to BIN.

Code: [Select]
open window 640,512

slowdown=0

dim grid(42,54)
dim cs(360),sn(360)

data 66714624,66584830,34145280
data 34078858,116383736,116391819
data 10485768,77594664,130015208
data 128966563,66600,34099362
data 130088,66605310,66613288
data 66706686,34099240,34145418,112188654
data 49248171,10486914,35672104,117431534
data 49272803,35672104,34083970,60837928
data 66591998,27385070,58850304,18941058
data 42009600,123854010,50296831,4214946
data 33570816,130145518,66025455,66690
data 2688040,130302,3800104,130302,238
data 87170,130,134174595,16773307,57
data 8392872,134174603,12570795,87178
data 10506370,130286,10506494,66714760
data 62410814,34145416,34099234,101676942
data 48783331,20482,34095104,101703662
data 62422927,34078760,10485896,66584632
data 10486008,0,60947710,0,35718274
data 0,50272131,0,33558529,0,50296707
data 0,35734658,0,65142014

for y=0 to 41
read a,b
for x=0 to 26
decode=2^(26-x)
if decode>b then
grid(y,x)=0
else
grid(y,x)=1
b=b-decode
fi
decode=2^(26-x)
if decode>a then
grid(y,x+27)=0
else
grid(y,x+27)=1
a=a-decode
fi
next x
next y
factor=(atan(1)*8)/360
for a=0 to 359
ang=a*factor
sn(a)=sin(ang)*.1
cs(a)=cos(ang)*.1
next a
px=3
py=1
head=182

label main
setdispbuf db
db=1-db
setdrawbuf db
setrgb 1,0,100,130
fill rectangle 0,0 to 640,256
setrgb 1,40,40,40
fill rectangle 0,256 to 640,512

j=peek("port1")
if and(j,32)<>0 head=mod(head+5,360)
if and(j,128)<>0 head=mod(head+360-5,360)
if and(j,16)<>0 then
newpx=px-(sn(head))*3
newpy=py-(cs(head))*3
if grid(newpx,newpy)=0 then
px=newpx
py=newpy
fi
fi
if and(j,64)<>0 then
newpx=px+(sn(head))*3
newpy=py+(cs(head))*3
if grid(newpx,newpy)=0 then
px=newpx
py=newpy
fi
fi
x1=0
for sc=head-31 to head+32 step 2
ang=mod(sc,359)
if ang<0 ang=ang+359
spx=sn(ang)
spy=cs(ang)
setrgb 1,255,0,0
fill box 320+px*2,56+py*2,322+px*2,58+py*2
xx=px
yy=py
l=0
repeat
xx=xx-spx
yy=yy-spy
l=l+1
k=grid(xx,yy)
until (k>0)
dd=1024/l
h=dd+dd
dt=256-dd
setrgb 1,140-dt*.5,140-dt*.5,140-dt*.5
fill box x1,dt,x1+20,256+h*.5
setrgb 1,0,0,0
box x1+2,dt+2,x1+20-2,256+h*.05
box x1+20-2,256+h*.05,x1+2,256+h*.5
x1=x1+20
next sc
for y=0 to 53
for x=0 to 41
if grid(x,y)>0 then
setrgb 1,0,0,0
fill box 320+x*2,56+y*2 to 322+x*2,58+y*2
fi
next x
next y
wait slowdown
goto main


Overall, a great piece of code. Very nice graphical effects with the bricks!
« Last Edit: January 11, 2007 by CLANKY »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #21 on: January 11, 2007 »
Thanks a million Clanky, this is excellent. Would it be possible if I could get a link to the original one? You're right it is fast, damn fast. Oh and that technique for using binary for the map, that's called packed data feilds its commonly used in assembler I already use it in all my code I found that on the PS2 any game that used whole bytes might take up to a minute to parse (very painful when testing a near complete game) but by switching to packed data those same games parsed in seconds. I've been using it ever since I recommend it to anyone. Thanks again for the code bud. I'm gonna have fun rippin this apart.

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #22 on: January 11, 2007 »
True this raycaster runs faster, but it is not a faster algorithm. It casts only 33 rays and I clocked the fps for the above at just under 80 fps on my celeron. My own caster uses 160 rays by default and I was surprised that it only reached 30 odd fps so I turned down the amount of rays to 33 and the fps shot up to about 100 and it reached between 125 and 140 fps without the texture maps (depending on wether you spend that time looking across an open space or staring at a wall) Still you're right 30 odd frames per second is is pretty slow I'll make sure that the final release has this fixed.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Yabasic Rocks !!!
« Reply #23 on: January 11, 2007 »
I think your routine also scans correctly, whereas this one takes baby steps across the map so as to avoid missing walls.  It still doesn't always work.

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #24 on: January 11, 2007 »
I know that one. I had that problem too, mine still misses the edges of  the walls. When the ray travels beyond the target tyle and enters the next one. Had to decrease the distance rays traveled in one jump to 0.1 meter when it was 0.5 meter sharp corners simply didn't exist. Still I can't see myself getting even 50 fps and still hold on to the textures. It just aint gonna happen. An I aint letting them go. Must be another way to find some speed maybe by reworking the intersections... Ah well back to the drawing board.

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Yabasic Rocks !!!
« Reply #25 on: January 11, 2007 »
There are some good tutorials on the net that show how to jump a whole grid square at a time without missing anything.  Try googling while I see if I can find the link again.

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #26 on: January 11, 2007 »

Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: Yabasic Rocks !!!
« Reply #27 on: January 12, 2007 »
Heres the link to the code I posted:
http://p205.ezboard.com/fyabasicprogrammingfrm2.showMessage?topicID=294.topic

It's at the eeky Ezboard Forums... you can have a look around, some really good toutorials and codes at that board.
Yes, I guess this one is simplier - no textured walls. But it is still a nice base for a 3D shooter engine.
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #28 on: January 12, 2007 »
Indeed it is thanks for the link bud, I think I might be able to squeze some more frames out by casting the first ray to both nearest longitudal and lateral grid lines so that I can then simply project on to the next lines instead of increasing the rays distance at the same steady rate this way I will know the right face Im dealin with from the get go instead of havin to calculate intersection points for faces that need not be considered thus eliminating two for - next loops (one for plotting intersection the other checking for distance) This is still on the writing pad though. Thank you

Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Yabasic Rocks !!!
« Reply #29 on: January 16, 2007 »
Here's the link I was thinking of.
http://www.permadi.com/tutorial/raycast/index.html

Jim
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #30 on: January 16, 2007 »
Karma for that, Jim. This is better than source code, it actually explains the technique very clearly and the part about looking up/down never thought it could be done in a raycaster btw got the rays projectin straight to lines now loads faster and always hits the right targets think I will go over the link a few more times to see what else I'm missin. Best tutorial I ever saw for rayscastin

Edit -

My textures are done the same as in the tutorial thats excellent one less thing to fix. One thing I didnt do the same is I use only angles, no projection plane maybe I should change that, the plane seems more versatile lets the camera move vertically as well as look up/down thanks again
« Last Edit: January 16, 2007 by rain_storm »

Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #31 on: January 21, 2007 »
I have updated this code and have zipped the original post. Its alot better now running at 80 fps with weather effects and some minor alterations / additions. Thanks for the tutorial Jim it has really made a big difference. Hope you all like the changes. The new version can be found on the first post of this thread.

Challenge Trophies Won:

lilw4t3rdr0p

  • Guest
Re: Yabasic Rocks !!!
« Reply #32 on: January 21, 2007 »
Very cool!

Karma up!

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #33 on: January 21, 2007 »
Thanks Lilly I appreciate that

Challenge Trophies Won:

Offline Clanky

  • Laser Guided Memories
  • Amiga 1200
  • ****
  • Posts: 340
  • Karma: 16
  • kiss that sound that pounds your senses
    • View Profile
Re: Yabasic Rocks !!!
« Reply #34 on: January 21, 2007 »
Geez! That's awesome!!! Never knew YaBASIC could create such good programs!
Nice updates by the way... runs really smooth... and I like the way you have made the keyboard keys the defaults in the game, instead of using the X,O etc yab defaults - karma!

Although, the drawback is the wheather, it seems that there is too much rain falling, because the rects are thick, it doesn't guite give the feeling of real rain? Maybe tone it down abit, but it's up to you!

Nice progress on the program...

I have just been mucking around with the other RayCaster program, lol... never could ray cast myself! lol...

Cheers
« Last Edit: January 21, 2007 by CLANKY »
He tilts, and his eyes are focused on the ground far below.. Wind? Angels? Men..

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #35 on: January 21, 2007 »
Ya like that! (Thanks)
I know what you mean about the rain but I added a slight wind effect so they drawn as lines not rects thats as thin as it goes I will be reducing the number of raindrops when I get around to adding splashes and ripples but this is coming along nicely! thanks for the Karma buddy

Challenge Trophies Won:

Offline Yaloopy

  • Death From Above
  • DBF Aficionado
  • ******
  • Posts: 2876
  • Karma: 35
    • View Profile
    • UltraPaste
Re: Yabasic Rocks !!!
« Reply #36 on: January 21, 2007 »
That's lookinh great, man!
Fuck L. Ron Hubbard and fuck all his clones.
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #37 on: January 21, 2007 »
Thanks Loopy great to see you still check out Yabasic stuff

Edit -

I just put a picture in below the download and every surface has a splash now too. I reackon this one is done and dusted, now I haven't the foggiest what to do next. Maybe a graphics demo.
« Last Edit: January 21, 2007 by rain_storm »

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Yabasic Rocks !!!
« Reply #38 on: January 21, 2007 »
I just had to press your Karma button :) That is one of the nicest raycasters I've ever seen in Yabasic and I've seen quite a few. The lightning and rain is a really nice touch. Textures are good as well. Nice stuff!

Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Yabasic Rocks !!!
« Reply #39 on: January 21, 2007 »
Thanks, I aim to please

Challenge Trophies Won: