future game ?

Vragen en suggesties over het programmeren van spelletjes, sprites en dergelijke in Liberty BASIC

Moderator: anthonio

future game ?

Berichtdoor bluatigro » di maart 01, 2011 10:23 pm

deze text staat ook op :
http://libertybasic.conforums.com
bij enclopidie

je kom er vanzelf via post : mythbusting by computer [ liberty code ]

bonan tagon

i m trying the same with OOP object$
this is what i got sofar
more graphisc wil be addaed later
i ma thinking about anaglyph . good idea ?

when finised who wants to build the GUI ?

WARNING :
test if this gives good results

cannon Vxyz = 0,0,0

in the far future this can be a nice game

[ hoek = angle in dutch ]

saluton


Wijziging door Gordon:
Code verwijderd. Te veel errors waardoor het programma LB laat hangen.
bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm

Re: future game ?

Berichtdoor Gordon » do maart 03, 2011 5:45 pm

Hoi Bluatigro,

Ik krijg jouw listing niet aan de praat.
Zelfs niet nadat ik 22 bugs uit je listing gehaald heb.

Hier is een listing zonder de 22 bugs.
De listing hangt!!!! als de timer het volgende stuk
Code: Selecteer alles
   ' if val( word$( now$ , 2 )) then
   '   timer 0
  ' end if

uitgevoerd wordt.




Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight

global winx , winy , pi
global hoeka , hoekb , barrel , speed , now$
winx = WindowWidth
winy = WindowHeight
button #m.btnfure , "fire"  , [fire] , ul , 50 , 50 , 200 , 100

open "cannon" for graphics as #m
   #m "trapclose [quit]"
   hoeka = 45
   prompt "angle a = " ; hoeka
   hoekb = 45
   prompt "angle b = " ; hoekb
   barrel = 50
   prompt "len barrel = "  ; barrel
   speed = 10
   prompt "speed = " ; speed

wait
'end

[fire]
   q1$ = cannon$( hoeka , hoekb , barrel , speed )
   q2$ = spark$( q1$ )
   now$ = fire$( q2$ )
   timer 40, [tmr]
wait

[tmr]
   now$ = fly$( now$ , 1000 / 40 )
   call lino 0,0,0 _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) , 10
   call ball _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) ,10

   ' if val( word$( now$ , 2 )) then
   '   timer 0
  ' end if
wait

[quit]
  close #m
end

function tox( x , y , z )
   x = x / ( z + 1000 ) * 1000
   tox = winx / 2 + x
end function

function toy( x , y , z )
   y = y / ( z + 1000 ) * 1000
   toy = winy / 2 - y
end function

sub lino x1 , y1 , z1 , x2 , y2 , z2 , thick
   a1 = tox( x1 , y1 , z1 )
   b1 = tox( x1 , y1 , z1 )
   a2 = tox( x1 , y1 , z1 )
   b2 = tox( x1 , y1 , z1 )
   #m "down"
   #m "size " ; thick
   #m "line " ; a1 ; " " ; b1 ; " " ; a2 ; " " ; b2
   #m "up"
end sub

sub ball x , y , z , d
   a = tox( x1 , y1 , z1 )
   b = tox( x1 , y1 , z1 )
   d = d / ( z + 1000 ) * 1000
   #m "goto ";a;" ";b
   #m "down"
   #m "circle " ; d
   #m "up"
end sub

function Vxyz$( x , y , z )
   Vxyz$ =x ; " " ; y ; " " ; z
end function

function cannon$( pan , tilt , Leng , V)
  cannon$ = pan; " "  ; tilt ; " "  ; Leng  ; " " ; V
end function

function spark$( object$ )
    pan = val( word$( object$ , 1 ))
    tilt = val( word$( object$ , 2 ))
    x = val( word$( object$ , 3 ))
    dx = val( word$( object$ , 4 ))
    call rotate dx , dz , pan
    call rotate x , z , pan
    call rotate dx , dy , tilt
    call rotate x , y , tilt
    spark$ = Vxyz$( x , y , z ) ; " " ; Vxyz$( dx , dy , dz )
end function

sub rotate byref k , byref l , deg
   s = sin( rad( deg ) )
   c = cos( rad( deg ) )
    hk = k * c - l * s
    hl  = k * s + l * c
    k = hk : l = hl
end sub

function fire$( bal$ )
    x = val( word$( bal$ , 1 ))
    y = val( word$( bal$ , 2 ))
    z = val( word$( bal$ , 3 ))
    fire$ = Vxyz$( x , y , z )
end function

function fly$( bal$ , time )
    x = val( word$( bal$ , 1 ))
    y = val( word$( bal$ , 2 ))
    z = val( word$( bal$ , 3 ))
    dx = val( word$( bal$ , 4 )) * time
    dy = val( word$( bal$ , 5 )) * time
    dz = val( word$( bal$ , 6 )) * time
    fly$ = Vxyz$( x + dx _
    , y + dy - 9.81* time _
    , z + dz )
end  function

function rad( deg )
   rad = deg * pi / 180
end function


Gordon

Ik raad u aan deze listing niet te downloaden als u
beginner bent. Buatigro heeft beloofd een andere listing
te uploaden.
Avatar gebruiker
Gordon
Site Admin
 
Berichten: 684
Geregistreerd: zo mei 22, 2005 12:50 am

Re: future game ?

Berichtdoor bluatigro » zo maart 06, 2011 10:09 pm

versie : 7/3/2011 17:10
ik kan dit nu niet testen gordon
je weet wel waarom

kijk evern bij de REMed code of t zo klopt en test t

Code: Selecteer alles
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight

global winx , winy , pi
global hoeka , hoekb , barrel , speed , now$
winx = WindowWidth
winy = WindowHeight
button #m.btnfure , "fire"  , [fire] , ul , 50 , 50 , 200 , 100

open "cannon" for graphics as #m
   #m "trapclose [quit]"
   hoeka = 45
   prompt "angle a = " ; hoeka
   hoekb = 45
   prompt "angle b = " ; hoekb
   barrel = 50
   prompt "len barrel = "  ; barrel
   speed = 10
   prompt "speed = " ; speed

wait
'end

[fire]
   q1$ = cannon$( hoeka , hoekb , barrel , speed )
   q2$ = spark$( q1$ )
   now$ = fire$( q2$ )
   timer 40, [tmr]
wait

[tmr]
   now$ = fly$( now$ , 1000 / 40 )
   call lino 0,0,0 _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) , 10
   call ball _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) _
   , val( word$( now$ , 1 )) ,10

   ' if val( word$( now$ , 2 )) then
   '   timer 0
  ' end if
wait

[quit]
  close #m
end

function tox( x , y , z )
   x = x / ( z + 1000 ) * 1000
   tox = winx / 2 + x
end function

function toy( x , y , z )
   y = y / ( z + 1000 ) * 1000
   toy = winy / 2 - y
end function

sub lino x1 , y1 , z1 , x2 , y2 , z2 , thick
   a1 = tox( x1 , y1 , z1 )
   b1 = tox( x1 , y1 , z1 )
   a2 = tox( x1 , y1 , z1 )
   b2 = tox( x1 , y1 , z1 )
   #m "down"
   #m "size " ; thick
   #m "line " ; a1 ; " " ; b1 ; " " ; a2 ; " " ; b2
   #m "up"
end sub

sub ball x , y , z , d
   a = tox( x1 , y1 , z1 )
   b = tox( x1 , y1 , z1 )
   d = d / ( z + 1000 ) * 1000
   #m "goto ";a;" ";b
   #m "down"
   #m "circle " ; d
   #m "up"
end sub

function Vxyz$( x , y , z )
   Vxyz$ =x ; " " ; y ; " " ; z
end function

function cannon$( pan , tilt , Leng , V)
  cannon$ = pan; " "  ; tilt ; " "  ; Leng  ; " " ; V
end function

function spark$( object$ )
    pan = val( word$( object$ , 1 ))
    tilt = val( word$( object$ , 2 ))
    x = val( word$( object$ , 3 ))
    dx = val( word$( object$ , 4 ))
    call rotate dx , dz , pan
    call rotate x , z , pan
    call rotate dx , dy , tilt
    call rotate x , y , tilt
    spark$ = Vxyz$( x , y , z ) ; " " ; Vxyz$( dx , dy , dz )
end function

sub rotate byref k , byref l , deg
   s = sin( rad( deg ) )
   c = cos( rad( deg ) )
    hk = k * c - l * s
    hl  = k * s + l * c
    k = hk : l = hl
end sub

function fire$( bal$ )
    x = val( word$( bal$ , 1 ))
    y = val( word$( bal$ , 2 ))
    z = val( word$( bal$ , 3 ))
    fire$ = Vxyz$( x , y , z )
end function

function fly$( bal$ , time )
    x = val( word$( bal$ , 1 ))
    y = val( word$( bal$ , 2 ))
    z = val( word$( bal$ , 3 ))
    dx = val( word$( bal$ , 4 )) * time
    dy = val( word$( bal$ , 5 )) * time
    dz = val( word$( bal$ , 6 )) * time
    fly$ = Vxyz$( x + dx _
    , y + dy - 9.81* time _
    , z + dz )
end  function

function rad( deg )
   rad = deg * pi / 180
end function

bluatigro
 
Berichten: 306
Geregistreerd: za sep 27, 2008 6:01 pm


Keer terug naar Games

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers. en 1 gast

cron