All pastes #297730 Raw Edit

Stuff

public text v1 · immutable
#297730 ·published 2006-12-31 07:07 UTC
rendered paste body
`Created by David
`18/12/06
`----------------
`Name: Undecided
`Genre: Arcade Style Fighting Game

sync on : sync rate 60
backdrop on
color backdrop RGB(255,0,0)
hide mouse
autocam off

`Load Objects
`---skip this for now, use primitives---
load image "image.png",1
load image "lava.jpg",2
load object "skull.x",500
gosub MakePrimitives
gosub DeclaringVariables
gosub Lighting
do

if mouseclick()=1 and NormalAttack=0
   gosub NormalAttack
   NormalAttack=1
endif

if NormalAttack=1
   if object exist(10)=1
      move object 10,10
      if Object Position X(10)>1100 or Object Position Z(10)>1100 or Object Position X(10)<-1100 or Object Position Z(10)<-1100
         delete object 10
         Normalattack=0
      endif
   endif
endif

if mouseclick()=2 and MeleeAttack=0
   MeleeAttack=1
   gosub MeleeAttack
endif

gosub PositionP1

gosub Stats

gosub Jumping

gosub Movement

gosub Death

gosub ThirdPersonCam

gosub MakeEnemies

gosub EnemyGravity

gosub PositionEnemies

gosub KillEnemy

gosub RePosEnemy

gosub EnemyAttack

gosub EnemyMoveAttack

gosub MoveEnemy

gosub EnemyDodge

gosub Setupenemyshot

gosub EnemyJump

gosub KnockBack

gosub MeleeAttackTimer

sync
loop

`Declares the Variables required to run the game (does not include player position)
DeclaringVariables:
   XDist#=200.0: YDist#=200.0: ZDist#=200.0
   enemyamount=3
   type EnemyLocation
      x
      z
      y
      alive
      counter
      movecounter
      enemyshoot
      jump
      jumpspeed#
      jumpspeedset
      dodging
      dodgetimer
   endtype
   dim enemylocation(enemyamount+20) as EnemyLocation
   for a=20 to enemyamount+19
      enemylocation(a).alive=0
      enemylocation(a).counter=rnd(2)+3
      enemylocation(a).movecounter=0
      enemylocation(a).enemyshoot=0
   next a
   alive=1
   MeleeAttack=0
   MeleeAttackTimer=0
return

`Controls all the variables responsible for jumping and also gravity
Jumping:
   IF SPACEKEY()=1 AND Jumping#=0 THEN Jump#=1

   IF Jump#=1
      Jump_Speed#=5
      Jumping#=1
      Jump#=0
   ENDIF

   IF Jumping#=1
      DEC Jump_Speed#,.1
      POSITION OBJECT 1,X#,Y#+Jump_Speed#,Z#
   ENDIF

   IF Object Collision (1,5)=1
      Jumping#=0
   ELSE
      IF Jumping#=0
      Jumping#=1: Jump_Speed#=-3
      ENDIF
   ENDIF
return

`Points P1 in the right direction and also rotates the camera
ThirdPersonCam:
   MMx = Mousemovex()/3
   Xc# = WrapValue(Xc# + MMx)
   Zc# = WrapValue(Zc# + MMx)
   Position Camera newxvalue(Object Position X(1),Xc#,XDist#),newyvalue(Object Position Y(1)+50,10.0,0),newzvalue(Object Position Z(1),Zc#,ZDist#)
   Yrotate Object 1,WrapValue(Camera Angle Y()+MMx)
   Point Camera Object Position X(1),Object Position Y(1),Object Position Z(1)
return

`Makes the primitives to play the game
MakePrimitives:
   make object sphere 1,50
   color object 1,RGB(255,0,255)

   make object box 5,1000,1000,3
   color object 5,0
   XROTATE OBJECT 5,-90
   position object 5,0,-100,0
   texture object 5,1
return

`Places P1 at the correct coordinates
PositionP1:
   if alive=1
      X#=OBJECT POSITION X(1)
      Y#=OBJECT POSITION Y(1)
      Z#=OBJECT POSITION Z(1)
      position object 1,X#,Y#,Z#
   endif
   if alive=0
      inc alivecounter
   endif
   if alivecounter>300
      alivecounter=0
      alive=1
   endif
return

`Shows status of the game (camera position, fps, etc)
Stats:
   ink RGB(0,255,0),0
   FPS#=SCREEN FPS()
   TEXT 0,0,"FPS: "+STR$(FPS#)
   TEXT 0,20,"CAMERA POSITION: "+STR$(cpx)+","+STR$(cpy)+","+STR$(cpz)
   TEXT 0,40,"EnemyShoot: "+STR$(enemylocation(20).enemyshoot)
   TEXT 0,60,"SCORE: "+STR$(score)
   TEXT 0,80,"Counter: "+STR$(enemylocation(20).counter)
   TEXT 0,100,"MoveCounter: "+STR$(enemylocation(20).movecounter)
   TEXT 0,120,"Enemy Y Pos: "+STR$(enemylocation(20).y)
   TEXT 0,140,"Dodge Variable: "+STR$(enemylocation(20).dodging)
   TEXT 0,160,"Dodge Timer: "+STR$(enemylocation(20).dodgetimer)
   TEXT 0,180,"Enemy Jump Speed: "+STR$(enemylocation(20).jumpspeed#)
   TEXT 0,200,"KnockBackTime: "+STR$(KnockBackTime)
   TEXT 0,220,"Melee Attack: "+STR$(MeleeAttack)
   TEXT 0,240,"Melee Attack Timer: "+STR$(MeleeAttackTimer)
   cpx=camera position x()
   cpy=camera position y()
   cpz=camera position z()
return

`Controls player movement using the keys WASD
Movement:
   if object exist(1)=1
      IF KEYSTATE(17)=1
         MOVE OBJECT 1,4
      ENDIF

      IF KEYSTATE(31)=1
         MOVE OBJECT 1,-4
      ENDIF

      IF KEYSTATE(30)=1
         MOVE OBJECT LEFT 1,3
      endif

      IF KEYSTATE(32)=1
         MOVE OBJECT RIGHT 1,3
      endif
   endif
return

NormalAttack:
   make object sphere 10,10
   texture object 10,2
   position object 10,X#,Y#+20,Z#
   set object to object orientation 10,1
   gosub EnemySetDodgeVar
return

MakeEnemies:
   for a=20 to enemyamount+19
      if object exist(a)=0
         make object sphere a,50
         color object a,RGB(0,0,0)
         enemylocation(a).x=rnd(500)-500
         enemylocation(a).z=rnd(500)-500
         enemylocation(a).y=1000
         position object a,enemylocation(a).x,enemylocation(a).y,enemylocation(a).z
         enemylocation(a).alive=1
      endif
   next a
return

EnemyGravity:
   for a=20 to enemyamount+19
      if OBJECT EXIST (a)=1
         if OBJECT COLLISION (a,5)=0
            if enemylocation(a).jump=0
               enemylocation(a).y=enemylocation(a).y-5
            endif
         endif
      endif
   next a
return

PositionEnemies:
   for a=20 to enemyamount+19
      if object exist (a)=1
         position object a,enemylocation(a).x,enemylocation(a).y,enemylocation(a).z
      endif
   next a
return

KillEnemy:
   for a=20 to enemyamount+19
      if object exist (a)=1
         if object exist (10)=1
            if object hit (a,10)=1
               delete object a
               inc score,100
               NormalAttack=0
               delete object 10
            endif
         endif
      endif
   next a
return

RePosEnemy:
   for a=20 to enemyamount+19
      if object exist(a)=1
         if OBJECT POSITION Y(a)<-2000
            delete object a
         endif
      endif
   next a
return

EnemyAttack:
   for a=20 to enemyamount+19
      if object exist(a)=1
      point object a,X#,Y#,Z#
      if object exist (a+100)=0
         if enemylocation(a).enemyshoot=0 and (enemylocation(a).y-Y#)^2<400
            make object sphere a+100,20
            position object a+100,enemylocation(a).x,enemylocation(a).y,enemylocation(a).z
            set object to object orientation a+100,a
            enemylocation(a).enemyshoot=RND(300)+100
         endif
      endif

         if enemylocation(a).movecounter=400
            enemylocation(a).movecounter=0
            enemylocation(a).counter=rnd(2)+3
         endif
      endif
   next a
return

MoveEnemy:
   for a=20 to 19+enemyamount
      if object exist(a)=1
         if enemylocation(a).counter=0 and enemylocation(a).movecounter<500
            point object a,X#,Y#,Z#
            move object a,3
            inc enemylocation(a).movecounter
            enemylocation(a).x=Object Position x(a)
            enemylocation(a).z=Object Position z(a)
         endif
      endif
   next a
return

EnemyMoveAttack:
   for a=20 to enemyamount+19
      if object exist(a+100)=1
         move object a+100,15

      if object hit(a+100,1)=1
         delete object a+100
         enemylocation(a).enemyshoot=RND(100)+100
      endif

      if object exist(a+100)=1
         if Object Position X(a+100)>1100 or Object Position Z(a+100)>1100 or Object Position X(a+100)<-1100 or Object Position Z(a+100)<-1100
            delete object a+100
            if enemylocation(a).counter>0
               dec enemylocation(a).counter
            endif
            enemylocation(a).enemyshoot=RND(300)+100
         endif
      endif
      endif
   next a
return

Death:
   if Object Position Y(1)<-2000
      Position Object 1,0,30,0
      Jumping#=0
   endif
   for a=20 to enemyamount+10
      if object exist(a+100)=1
         if object hit(a+100,1)=1
            delete object a+100
            delete object 1
            alive=0
         endif
      endif
   next a
return

EnemyDodge:
   for a=20 to enemyamount+19
      if object exist(a)
         if object exist(10)
            if intersect object (a,object position x(10),object position y(10),object position z(10),enemylocation(a).x,enemylocation(a).y,enemylocation(a).z)<200
                  if enemylocation(a).dodging=0
                     if enemylocation(a).dodgetimer>0
                        move object left a,4
                        enemylocation(a).x=object position x(a)
                        enemylocation(a).z=object position z(a)
                        dec enemylocation(a).dodgetimer
                     endif
                  endif
                  if enemylocation(a).dodging=1
                     if enemylocation(a).dodgetimer>0
                        move object right a,4
                        enemylocation(a).x=object position x(a)
                        enemylocation(a).z=object position z(a)
                        dec enemylocation(a).dodgetimer
                     endif
                  endif
                  if enemylocation(a).dodging=2
                     if enemylocation(a).jumpspeedset=0
                        enemylocation(a).jumpspeed#=5.6
                        enemylocation(a).jumpspeedset=1
                     endif
                  endif
            endif
         endif
      endif
   next a
return

Setupenemyshot:
   for a=20 to enemyamount+19
      if enemylocation(a).enemyshoot>0
         dec enemylocation(a).enemyshoot
      endif
   next a
return

EnemyJump:
   for a=20 to enemyamount+19
      if enemylocation(a).jumpspeedset=1
         if enemylocation(a).jumpspeed#>-5.6
            enemylocation(a).jump=1
            enemylocation(a).y=enemylocation(a).y+enemylocation(a).jumpspeed#
            dec enemylocation(a).jumpspeed#,.2
         endif
         if enemylocation(a).jumpspeed#<-5.6
            enemylocation(a).jump=0
            enemylocation(a).jumpspeedset=0
            enemylocation(a).jumpspeed#=0
         endif
      endif
   next a
return

EnemySetDodgeVar:
   for a=20 to enemyamount+19
      enemylocation(a).dodging=RND(2)
      enemylocation(a).dodgetimer=30
   next a
return

Lighting:
   Position Light 0,500,200,500
   point light 0,0,0,0
   Make Light 1
   Position Light 1,-500,200,-500
   point light 1,0,0,0
return

MeleeAttack:
   for a=20 to enemyamount+19
      play object 1,1,10
      if object hit(1,a)
         KnockBack=1
         KnockBackID=a
         KnockBackTime=20
      endif
   next a
   MeleeAttackTimer=20
return

KnockBack:
   if KnockBack=1
      if KnockBackTime>0
         dec KnockBackTime
         move object KnockBackID,-3
         enemylocation(KnockBackID).x=Object Position X(KnockBackID)
         enemylocation(KnockBackID).z=Object Position Z(KnockBackID)
      endif
      If KnockBackTime<1
         KnockBack=0
      endif
   endif
return

MeleeAttackTimer:
   if MeleeAttackTimer>0
      dec MeleeAttackTimer
   endif
   if MeleeAttackTimer=0
      MeleeAttack=1
   endif
return