Rem ***** Included Source File *****
REM KIDA BETEG KONSZEPTJE

Rem Inicializálás
Rem Autocam off
Hide Mouse
Sync On : Sync Rate 60

Rem Globális változók

Rem TPS Sugár
Global TPS_R As Float : TPS_R=30

Rem Karakter
Global Karakter As Integer : Karakter=FreeObject()

Rem Ugrás változók
Global MaxY# as Float : MaxY#=5.0
Global SzintY# as Float : SzintY#=MaxY#-0.3
Global DeltaY# as Float : DeltaY#=0.1
Global Jump as Boolean : Jump=0
Global yPuffer# as Float
Global Mozgas$ : Mozgas$="elore"


Rem Debug Matrix
Make matrix 1,100,100,25,25

Rem TPS Kamera
Global Self As Integer : Self=1
Make object cube Self,10 : Hide object Self

Rem Karakter Betöltése
Make object box Karakter, 5,10,5


Rem Main Loop
Do

 Rem Alprogramok meghívása
 Gosub Control_Karakter
 Gosub Control_Camera
 Gosub Debug

 Rem Képernyő frissítés
 Sync
Loop

Rem Kamera kezelő alprogram
Control_Camera:

 Rem Egér
 Rotate object Self, Object Angle X(Self)+MouseMoveY(),Object Angle Y(Self)+MouseMoveX(),0

 Rem Debug
 If Object Angle X(Self)<10 then xRotate Object Self,10
 If Object Angle X(Self)>50 then xRotate Object Self,50
 If Object Angle Y(Self)>360 then yRotate Object Self,0
 If Object Angle Y(Self)<0 then yRotate Object Self,360

 Rem Asszimilálódás
 Position camera Object Position X(Self),Object Position Y(Self)+yPuffer#,Object Position z(Self)
 Rotate camera Object Angle X(Self),Object Angle Y(Self),Object Angle Z(Self)

 Rem Sugár
 Move camera TPS_R*(-1)

Return

Rem Karakter kezelő alprogram
Control_Karakter:

Rem Karakter mozgatása
If not jump

 Mozgas$=""

 If keystate(17)
  Move object Karakter,0.5
  Position Object Self, Object Position X(Karakter),Object Position Y(Self),Object Position Z(Karakter)
  If not jump then Mozgas$="elore"
 Endif

 If keystate(31)
  Move object Karakter,-0.5
  Position Object Self, Object Position X(Karakter),Object Position Y(Self),Object Position Z(Karakter)
  If not jump then Mozgas$="hatra"
 Endif

 If keystate(32)
  yRotate object Karakter,Object Angle Y(Karakter)+90
  Move object Karakter,0.5
  yRotate object Karakter,Object Angle Y(Karakter)-90
  Position Object Self, Object Position X(Karakter),Object Position Y(Self),Object Position Z(Karakter)
  If not jump then Mozgas$="jobbra"
 Endif

 If keystate(30)
  yRotate object Karakter,Object Angle Y(Karakter)-90
  Move object Karakter,0.5
  yRotate object Karakter,Object Angle Y(Karakter)+90
  Position Object Self, Object Position X(Karakter),Object Position Y(Self),Object Position Z(Karakter)
  If not jump then Mozgas$="balra"
 Endif

 Rem Srég
 If keystate(17) and keystate(32) then Mozgas$="jobbfel"
  If keystate(17) and keystate(30) then Mozgas$="balfel"

 If keystate(31)
  If keystate(32) then Mozgas$="jobble"
  If keystate(30) then Mozgas$="balle"
 Endif

 Rem Mozgás vége
 Endif

 Rem Ugrás
 If spacekey() then Jump=1
 If Jump
 If Mozgas$="elore" then Move object Self,0.5
 If Mozgas$="hatra" then Move object Self,-0.5

 If Mozgas$="balra"
  yRotate object Self,Object Angle Y(Self)-90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)+90
 Endif

 If Mozgas$="jobbra"
  yRotate object Self,Object Angle Y(Self)+90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)-90
 Endif

 If mozgas$="balfel"
  Rem Fel
  Move object Self,0.5

  Rem Balra
  yRotate object Self,Object Angle Y(Self)-90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)+90
 Endif


 If mozgas$="jobbfel"
  Rem Fel
  Move object Self,0.5

  Rem Jobbra
  yRotate object Self,Object Angle Y(Self)+90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)-90
 Endif

  If mozgas$="jobble"
  Rem Fel
  Move object Self,-0.5

  Rem Jobbra
  yRotate object Self,Object Angle Y(Self)+90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)-90
 Endif

  If mozgas$="balle"
  Rem Fel
  Move object Self,-0.5

  Rem Balra
  yRotate object Self,Object Angle Y(Self)-90
  Move object Self,0.5
  yRotate object Self,Object Angle Y(Self)+90
 Endif

   yPuffer#=(yPuffer#+(MaxY#-yPuffer#)*DeltaY#)
   If yPuffer#>=SzintY# and DeltaY#>0 then DeltaY#=(-1)*DeltaY#
   If yPuffer#<=0.005 and DeltaY#<0
     Jump=0
     DeltaY#=DeltaY#*(-1)
     yPuffer#=0
   Endif

 Endif


 Rem Karakter szink
 Position Object Karakter, Object Position X(Self),yPuffer#,Object Position Z(Self)
 Position Object Self, Object Position X(Self),0,Object Position Z(Self)
 yRotate Object Karakter, Object Angle Y(Self)

Return


Rem Debug
Debug:
 Set Cursor 1,1
 Print "xAngle: ",Object Angle X(Self)
 Print "yAngle: ",Object Angle Y(Self)
 Print "FPS: ",Screen FPS()
 Print Jump
 Print "Y ",yPuffer#
 Print "DeltaY ",DeltaY#
 Print Object Position Y(Self)
 Print Mozgas$
Return



Rem ********** Függvények **********

Rem FreeObject
Function FreeObject()
 I=1
 Repeat
 I=I+1
 Until Object Exist(I)=0
Endfunction I

Rem ********************************