Qbasicnews.com
July 05, 2020, 03:27:12 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Battle Cars (AKA mathematical nightmare) completed!  (Read 7778 times)
Atom Ant
Member
*
Posts: 78



« on: April 07, 2005, 06:38:39 PM »

Ah, finally, my new game is complete.  I hope you enjoy it.  Sorry about the lack of directions in-game; I'll fill you in here.

Keys:

 - Player 1:
 - Q - Turn Left
 - E - Turn Right
 - W - Attack

 - Player 2:
 - I - Turn Left
 - P - Turn Right
 - O - Attack

Tips:

 - I don't suggest setting your movement speed to anything higher than 4.
 - Turning speed should be close to double the movement speed.
 - The AI in the 1-player game is stupid, but it is still very competitive.

Source Code:

(ignore "qbasic" heading, it will only run if compiled by freeBASIC)
[syntax="qbasic"]
DECLARE SUB AI (p1XCoor!, p1YCoor!, p1Angle!, p1Attack!, p1AttackAreaX!, p1AttackAreaY!, p2XCoor!, p2YCoor!, p2Angle!, p2Attack!, p2AttackAreaX!, p2AttackAreaY!, p1Distance!, p1MoveSpeed!, p1TurnSpeed!, p1Damage!, p1Range!, p1Health!, p2Distance!,  _
p2MoveSpeed!, p2TurnSpeed!, p2Damage!, p2Range!, p2Health!, powerUp!, powerUpType!, powerUpX!, powerUpY!, p2TurnLeft!, p2TurnRight!, powerUpFlag!)
DECLARE SUB healthBar (x!, y!, barColor!, health!)
DECLARE SUB drawBackground (outlineColor!, bgColor!)
DECLARE SUB graphicsEngine (graphic!(), graphicWidth!, graphicHeight!, xCoor!, yCoor!, negAngle!)
DECLARE FUNCTION keyCheck! (keyCode!)
DECLARE SUB graphicsLoader (graphic!())
DECLARE SUB particle (particleX!, particleY!, particleLength!, particleColor!)

DEFSNG A-Z

DIM player1Vehicle(5, 7)
DIM player2Vehicle(5, 7)
DIM powerUpSpeed(4, 4)
DIM powerUpTurn(4, 4)
DIM powerUpDamage(4, 4)
DIM powerUpRange(4, 4)
DIM powerUpHealth(4, 4)

RANDOMIZE TIMER

CONST pi = 3.141592652589793#

CONST true = 1
CONST false = 0

LET outlineColor = 15
LET bgColor = 8

LET collisionParticleLength = 50
LET damageParticleLength = 10

LET powerUpParticleColor = 4
LET powerUpParticleLength = 40
LET powerUpFrequency = 100
LET powerUpSpeedValue = 1
LET powerUpTurnValue = 1
LET powerUpDamageValue = 1
LET powerUpRangeValue = 3
LET powerUpHealthValue = 20

LET p1HealthBarX = 10
LET p1HealthBarY = 190

LET p2HealthBarX = 304
LET p2HealthBarY = 190

LET p1LeftKey = 16
LET p1RightKey = 18
LET p1AttackKey = 17

LET p2LeftKey = 23
LET p2RightKey = 25
LET p2AttackKey = 24

LET p1Distance = 50
LET p2Distance = 50

LET givenRange = 3

LET possiblePoints = 29

SCREEN 7, 0, 0, 0
DO WHILE players <> 1 AND players <> 2
   INPUT "1 or 2 players"; players
LOOP

CALL graphicsLoader(player1Vehicle())
CALL graphicsLoader(player2Vehicle())
CALL graphicsLoader(powerUpSpeed())
CALL graphicsLoader(powerUpTurn())
CALL graphicsLoader(powerUpDamage())
CALL graphicsLoader(powerUpRange())
CALL graphicsLoader(powerUpHealth())

DO
  SCREEN 7, 0, 0, 0
  COLOR 2

  LET pointsLeft = possiblePoints

  DO WHILE pointsLeft <> 0
    LET pointsLeft = possiblePoints

    FOR i = 1 TO 5
      CLS
   
      PRINT "Player 1, you have"; possiblePoints; "points to"
      PRINT "distribute between your movement"
      PRINT "speed, turning speed, damage,"
      PRINT "attack range, and health."
      PRINT
      PRINT pointsLeft; "Points left."
      PRINT

      IF i = 1 THEN
          INPUT "Movement speed"; p1InputedMoveSpeed
          LET p1MoveSpeed = ABS(p1InputedMoveSpeed)
          LET pointsLeft = pointsLeft - p1InputedMoveSpeed
        ELSEIF i = 2 THEN
          INPUT "Turning speed"; p1InputedTurnSpeed
          LET p1TurnSpeed = ABS(p1InputedTurnSpeed)
          LET pointsLeft = pointsLeft - p1InputedTurnSpeed
        ELSEIF i = 3 THEN
          INPUT "Damage"; p1InputedDamage
          LET p1Damage = ABS(p1InputedDamage)
          LET pointsLeft = pointsLeft - p1InputedDamage
        ELSEIF i = 4 THEN
          INPUT "Attack Range"; p1InputedRange
          LET p1Range = ABS(p1InputedRange)
          LET pointsLeft = pointsLeft - p1InputedRange
        ELSEIF i = 5 THEN
          INPUT "Health (x10)"; p1InputedHealth
          LET p1Health = ABS(p1InputedHealth)
          LET pointsLeft = pointsLeft - p1InputedHealth
      END IF
    NEXT i
  LOOP

  COLOR 14

  LET pointsLeft = possiblePoints

  DO WHILE pointsLeft <> 0 AND players = 2
    LET pointsLeft = possiblePoints

    FOR i = 1 TO 5
      CLS
     
      PRINT "Player 2, you have"; possiblePoints; "points to"
      PRINT "distribute between your movement"
      PRINT "speed, turning speed, damage,"
      PRINT "attack range, and health."
      PRINT
      PRINT pointsLeft; "Points left."
      PRINT

      IF i = 1 THEN
          INPUT "Movement speed"; p2InputedMoveSpeed
          LET p2MoveSpeed = ABS(p2InputedMoveSpeed)
          LET pointsLeft = pointsLeft - p2InputedMoveSpeed
        ELSEIF i = 2 THEN
          INPUT "Turning speed"; p2InputedTurnSpeed
          LET p2TurnSpeed = ABS(p2InputedTurnSpeed)
          LET pointsLeft = pointsLeft - p2InputedTurnSpeed
        ELSEIF i = 3 THEN
          INPUT "Damage"; p2InputedDamage
          LET p2Damage = ABS(p2InputedDamage)
          LET pointsLeft = pointsLeft - p2InputedDamage
        ELSEIF i = 4 THEN
          INPUT "Attack Range"; p2InputedRange
          LET p2Range = ABS(p2InputedRange)
          LET pointsLeft = pointsLeft - p2InputedRange
        ELSEIF i = 5 THEN
          INPUT "Health (x10)"; p2InputedHealth
          LET p2Health = ABS(p2InputedHealth)
          LET pointsLeft = pointsLeft - p2InputedHealth
      END IF
    NEXT i
  LOOP
 
  IF players = 1 THEN
    LET p2InputedMoveSpeed = INT(RND * 4 + 1)
    LET p2InputedTurnSpeed = INT(RND * 8 + 1)
    LET p2InputedDamage = INT(RND * 4 + 1)
    LET p2InputedRange = INT(RND * 10 + 1)
    LET p2InputedHealth = possiblePoints - (p2InputedMoveSpeed + p2InputedTurnSpeed + p2InputedDamage + p2InputedRange + p2InputedHealth)
  END IF

  DO
    SCREEN 7, 0, 1, 0
    COLOR 15

    LET p1Attack = false
    LET p1TurnLeft = false
    LET p1TurnRight = false

    LET p2Attack = false
    LET p2TurnLeft = false
    LET p2TurnRight = false
   
    LET p1MoveSpeed = p1InputedMoveSpeed
    LET p1TurnSpeed = p1InputedTurnSpeed
    LET p1Damage = p1InputedDamage
    LET p1Range = p1InputedRange
    LET p1Health = p1InputedHealth * 10

    LET p2MoveSpeed = p2InputedMoveSpeed
    LET p2TurnSpeed = p2InputedTurnSpeed
    LET p2Damage = p2InputedDamage
    LET p2Range = p2InputedRange
    LET p2Health = p2InputedHealth * 10

    LET p1Angle = INT(p1TurnSpeed * (INT(RND * (360 / p1TurnSpeed))))
    LET p2Angle = INT(p2TurnSpeed * (INT(RND * (360 / p2TurnSpeed))))

    LET p1XCoor = 50
    LET p1YCoor = 100
    LET p2XCoor = 270
    LET p2YCoor = 100

    CLS

    COLOR 4
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT
    PRINT "             On your mark!"
    CALL drawBackground(outlineColor, bgColor)
    CALL healthBar(p1HealthBarX, p1HealthBarY, 2, p1Health)
    CALL healthBar(p2HealthBarX, p2HealthBarY, 14, p2Health)
    CALL graphicsEngine(player1Vehicle(), 5, 7, p1XCoor, p1YCoor, p1Angle)
    CALL graphicsEngine(player2Vehicle(), 5, 7, p2XCoor, p2YCoor, p2Angle)
    PCOPY 1, 0
   
    LET elapsedTime = TIMER
    DO WHILE elapsedTime >= TIMER - 1
    LOOP

    COLOR 14
    PRINT
    PRINT "                Get set!"
    CALL drawBackground(outlineColor, bgColor)
    CALL healthBar(p1HealthBarX, p1HealthBarY, 2, p1Health)
    CALL healthBar(p2HealthBarX, p2HealthBarY, 14, p2Health)
    CALL graphicsEngine(player1Vehicle(), 5, 7, p1XCoor, p1YCoor, p1Angle)
    CALL graphicsEngine(player2Vehicle(), 5, 7, p2XCoor, p2YCoor, p2Angle)
    PCOPY 1, 0

    LET elapsedTime = TIMER
    DO WHILE elapsedTime >= TIMER - 1
    LOOP
   
    COLOR 2
    PRINT
    PRINT "                  Go!"
    CALL drawBackground(outlineColor, bgColor)
    CALL healthBar(p1HealthBarX, p1HealthBarY, 2, p1Health)
    CALL healthBar(p2HealthBarX, p2HealthBarY, 14, p2Health)
    CALL graphicsEngine(player1Vehicle(), 5, 7, p1XCoor, p1YCoor, p1Angle)
    CALL graphicsEngine(player2Vehicle(), 5, 7, p2XCoor, p2YCoor, p2Angle)
    PCOPY 1, 0

    LET elapsedTime = TIMER
    DO WHILE elapsedTime >= TIMER - 1
    LOOP
 
    LET elapsedTime = 0
   
    DO WHILE p1Health >= 0 AND p2Health >= 0
      DO WHILE TIMER - elapsedTime < 1 / 60
      LOOP
      LET elapsedTime = TIMER
   
      CLS
     
      LET unused$ = INKEY$
     
      IF keyCheck(p1LeftKey) = true THEN LET p1TurnLeft = true
      IF keyCheck(p1RightKey) = true THEN LET p1TurnRight = true
      IF keyCheck(p1AttackKey) = true THEN LET p1Attack = true
      IF keyCheck(p1LeftKey) = false THEN LET p1TurnLeft = false
      IF keyCheck(p1RightKey) = false THEN LET p1TurnRight = false
      IF keyCheck(p1AttackKey) = false THEN LET p1Attack = false

      IF players = 2 THEN
          IF keyCheck(p2LeftKey) = true THEN LET p2TurnLeft = true
          IF keyCheck(p2RightKey) = true THEN LET p2TurnRight = true
          IF keyCheck(p2AttackKey) = true THEN LET p2Attack = true
          IF keyCheck(p2LeftKey) = false THEN LET p2TurnLeft = false
          IF keyCheck(p2RightKey) = false THEN LET p2TurnRight = false
          IF keyCheck(p2AttackKey) = false THEN LET p2Attack = false
        ELSEIF players = 1 THEN
          CALL AI(p1XCoor, p1YCoor, p1Angle, p1Attack, p1AttackAreaX, p1AttackAreaY, p2XCoor, p2YCoor, p2Angle, p2Attack, p2AttackAreaX, p2AttackAreaY, p1Distance, p1MoveSpeed, p1TurnSpeed, p1Damage, p1Range, p1Health, p2Distance, p2MoveSpeed, p2TurnSpeed,  _
p2Damage, p2Range, p2Health, powerUp, powerUpType, powerUpX, powerUpY, p2TurnLeft, p2TurnRight, powerUpFlag)
      END IF

      IF p1TurnLeft = true THEN
        LET p1Angle = p1Angle + p1TurnSpeed
      END IF
      IF p1TurnRight = true THEN
        LET p1Angle = p1Angle - p1TurnSpeed
      END IF
      IF p2TurnLeft = true THEN
        LET p2Angle = p2Angle + p2TurnSpeed
      END IF
      IF p2TurnRight = true THEN
        LET p2Angle = p2Angle - p2TurnSpeed
      END IF

      IF p1XCoor <= 0 OR p1XCoor >= 319 OR p1YCoor <= 0 OR p1YCoor >= 199 THEN
        LET p1Angle = p1Angle + 180
      END IF
      IF p2XCoor <= 0 OR p2XCoor >= 319 OR p2YCoor <= 0 OR p2YCoor >= 199 THEN
        LET p2Angle = p2Angle + 180
      END IF
     
      IF p1Angle >= 360 THEN
        LET p1Angle = p1Angle - 360
          ELSEIF p1Angle < 0 THEN
        LET p1Angle = p1Angle + 360
      END IF
      IF p2Angle >= 360 THEN
        LET p2Angle = p2Angle - 360
          ELSEIF p2Angle < 0 THEN
        LET p2Angle = p2Angle + 360
      END IF
     
      LET p1XCoor = p1XCoor + (p1MoveSpeed * COS((-p1Angle - 90) * (pi / 180)))
      LET p1YCoor = p1YCoor + (p1MoveSpeed * SIN((-p1Angle - 90) * (pi / 180)))
      LET p2XCoor = p2XCoor + (p2MoveSpeed * COS((-p2Angle - 90) * (pi / 180)))
      LET p2YCoor = p2YCoor + (p2MoveSpeed * SIN((-p2Angle - 90) * (pi / 180)))
     
      CALL drawBackground(outlineColor, bgColor)
     
      IF p1XCoor >= p2XCoor - 6 AND p1XCoor <= p2XCoor + 6 AND p1YCoor >= p2YCoor - 6 AND p1YCoor <= p2YCoor + 6 THEN
        LET p1Health = p1Health / 2
        LET p2Health = p2Health / 2
        CALL particle(p1XCoor, p1YCoor, collisionParticleLength, 2)
        CALL particle(p1XCoor, p1YCoor, collisionParticleLength, 2)
        CALL particle(p2XCoor, p2YCoor, collisionParticleLength, 14)
        CALL particle(p2XCoor, p2YCoor, collisionParticleLength, 14)
      END IF
     
      CALL healthBar(p1HealthBarX, p1HealthBarY, 2, p1Health)
      CALL healthBar(p2HealthBarX, p2HealthBarY, 14, p2Health)
       
      IF powerUp = false THEN
          IF INT(RND * powerUpFrequency) = true THEN
            LET powerUpX = RND * 300 + 10
            LET powerUpY = RND * 180 + 10
            LET powerUpType = INT(RND * 5) + 1
            LET powerUp = true
            CALL particle(powerUpX, powerUpY, powerUpParticleLength, powerUpParticleColor)
            CALL particle(powerUpX, powerUpY, powerUpParticleLength, powerUpParticleColor)
            CALL particle(powerUpX, powerUpY, powerUpParticleLength, powerUpParticleColor)
          END IF
        ELSEIF powerUp = true THEN
          SELECT CASE powerUpType
            CASE IS = 1
              CALL graphicsEngine(powerUpSpeed(), 4, 4, powerUpX, powerUpY, 0)
              IF p1XCoor >= powerUpX - 5 AND p1XCoor <= powerUpX + 5 AND p1YCoor >= powerUpY - 5 AND p1YCoor <= powerUpY + 5 THEN
                  LET p1MoveSpeed = p1MoveSpeed + powerUpSpeedValue
                  LET powerUp = false
                ELSEIF p2XCoor >= powerUpX - 5 AND p2XCoor <= powerUpX + 5 AND p2YCoor >= powerUpY - 5 AND p2YCoor <= powerUpY + 5 THEN
                  LET p2MoveSpeed = p2MoveSpeed + powerUpSpeedValue
                  LET powerUp = false
              END IF
            CASE IS = 2
              CALL graphicsEngine(powerUpTurn(), 4, 4, powerUpX, powerUpY, 0)
              IF p1XCoor >= powerUpX - 5 AND p1XCoor <= powerUpX + 5 AND p1YCoor >= powerUpY - 5 AND p1YCoor <= powerUpY + 5 THEN
                  LET p1TurnSpeed = p1TurnSpeed + powerUpTurnValue
                  LET powerUp = false
                ELSEIF p2XCoor >= powerUpX - 5 AND p2XCoor <= powerUpX + 5 AND p2YCoor >= powerUpY - 5 AND p2YCoor <= powerUpY + 5 THEN
                  LET p2TurnSpeed = p2TurnSpeed + powerUpTurnValue
                  LET powerUp = false
              END IF
            CASE IS = 3
              CALL graphicsEngine(powerUpDamage(), 4, 4, powerUpX, powerUpY, 0)
              IF p1XCoor >= powerUpX - 5 AND p1XCoor <= powerUpX + 5 AND p1YCoor >= powerUpY - 5 AND p1YCoor <= powerUpY + 5 THEN
                  LET p1Damage = p1Damage + powerUpDamageValue
                  LET powerUp = false
                ELSEIF p2XCoor >= powerUpX - 5 AND p2XCoor <= powerUpX + 5 AND p2YCoor >= powerUpY - 5 AND p2YCoor <= powerUpY + 5 THEN
                  LET p2Damage = p2Damage + powerUpDamageValue
                  LET powerUp = false
              END IF
            CASE IS = 4
              CALL graphicsEngine(powerUpRange(), 4, 4, powerUpX, powerUpY, 0)
              IF p1XCoor >= powerUpX - 5 AND p1XCoor <= powerUpX + 5 AND p1YCoor >= powerUpY - 5 AND p1YCoor <= powerUpY + 5 THEN
                  LET p1Range = p1Range + powerUpRangeValue
                  LET powerUp = false
                ELSEIF p2XCoor >= powerUpX - 5 AND p2XCoor <= powerUpX + 5 AND p2YCoor >= powerUpY - 5 AND p2YCoor <= powerUpY + 5 THEN
                  LET p2Range = p2Range + powerUpRangeValue
                  LET powerUp = false
              END IF
            CASE IS = 5
              CALL graphicsEngine(powerUpHealth(), 4, 4, powerUpX, powerUpY, 0)
              IF p1XCoor >= powerUpX - 5 AND p1XCoor <= powerUpX + 5 AND p1YCoor >= powerUpY - 5 AND p1YCoor <= powerUpY + 5 THEN
                  LET p1Health = p1Health + powerUpHealthValue
                  LET powerUp = false
                ELSEIF p2XCoor >= powerUpX - 5 AND p2XCoor <= powerUpX + 5 AND p2YCoor >= powerUpY - 5 AND p2YCoor <= powerUpY + 5 THEN
                  LET p2Health = p2Health + powerUpHealthValue
                  LET powerUp = false
              END IF
          END SELECT
      END IF

      IF p1Attack = true THEN
        LET p1AttackAreaX = p1XCoor + (p1Distance * COS((-p1Angle - 90) * (pi / 180)))
        LET p1AttackAreaY = p1YCoor + (p1Distance * SIN((-p1Angle - 90) * (pi / 180)))
        CIRCLE (p1AttackAreaX, p1AttackAreaY), p1Range + givenRange, 2
        IF SQR((p1AttackAreaX - p2XCoor) ^ 2 + (p1AttackAreaY - p2YCoor) ^ 2) <= p1Range + givenRange THEN
          LET p2Health = p2Health - p1Damage
          CALL particle(p2XCoor, p2YCoor, p1Damage * damageParticleLength, 14)
          END IF
      END IF
      IF p2Attack = true THEN
        LET p2AttackAreaX = p2XCoor + (p2Distance * COS((-p2Angle - 90) * (pi / 180)))
        LET p2AttackAreaY = p2YCoor + (p2Distance * SIN((-p2Angle - 90) * (pi / 180)))
        CIRCLE (p2AttackAreaX, p2AttackAreaY), p2Range + givenRange, 14
        IF SQR((p2AttackAreaX - p1XCoor) ^ 2 + (p2AttackAreaY - p1YCoor) ^ 2) <= p2Range + givenRange THEN
          LET p1Health = p1Health - p2Damage
          CALL particle(p1XCoor, p1YCoor, p2Damage * damageParticleLength, 2)
        END IF
      END IF

      CALL graphicsEngine(player1Vehicle(), 5, 7, p1XCoor, p1YCoor, p1Angle)
      CALL graphicsEngine(player2Vehicle(), 5, 7, p2XCoor, p2YCoor, p2Angle)
       
      PCOPY 1, 0
    LOOP

    CLS

    PRINT

    IF p1Health >= 0 THEN
        COLOR 2
       
        PRINT " Player 1 is the winner!"
        PRINT
        PRINT " C - Continue with the current setups."
        PRINT " N - Create new setups."
        PRINT " X - Exit the game."
       
        CALL drawBackground(outlineColor, bgColor)
        CALL healthBar(p1HealthBarX, p1HealthBarY, 2, p1Health)
        CALL graphicsEngine(player1Vehicle(), 5, 7, p1XCoor, p1YCoor, p1Angle)
      ELSEIF p2Health >= 0 THEN
        COLOR 14
       
        PRINT " Player 2 is the winner!"
        PRINT
        PRINT " C - Continue with the current setups."
        PRINT " N - Create new setups."
        PRINT " X - Exit the game."
       
        CALL drawBackground(outlineColor, bgColor)
        CALL healthBar(p2HealthBarX, p2HealthBarY, 14, p2Health)
        CALL graphicsEngine(player2Vehicle(), 5, 7, p2XCoor, p2YCoor, p2Angle)
      ELSEIF p1Health < 0 AND p2Health < 0 THEN
        COLOR 15

        PRINT " A draw?!"
        PRINT
        PRINT " C - Continue with the current setups."
        PRINT " N - Create new setups."
        PRINT " X - Exit the game."
       
        CALL drawBackground(outlineColor, bgColor)
    END IF

    PCOPY 1, 0

    LET key$ = ""
    DO WHILE key$ <> "c" AND key$ <> "n" AND key$ <> "x"
      LET key$ = INKEY$
    LOOP
  LOOP WHILE key$ = "c"
LOOP WHILE key$ = "n"

END

'player 1 vehicle
DATA 5,7
DATA -1,-1,02,-1,-1
DATA -1,02,07,02,-1
DATA -1,02,07,02,-1
DATA 02,07,07,07,02
DATA 02,07,07,07,02
DATA 02,02,02,02,02
DATA -1,02,02,02,-1

'player 2 vehicle
DATA 5,7
DATA -1,-1,14,-1,-1
DATA -1,14,07,14,-1
DATA -1,14,07,14,-1
DATA 14,07,07,07,14
DATA 14,07,07,07,14
DATA 14,14,14,14,14
DATA -1,14,14,14,-1

'Speed power up
DATA 4,4
DATA 03,03,-1,-1
DATA -1,-1,03,03
DATA 03,03,-1,-1
DATA -1,-1,03,03

'Turn power up
DATA 4,4
DATA -1,01,01,-1
DATA 01,-1,-1,01
DATA 01,-1,-1,-1
DATA -1,01,01,01

'Damage power up
DATA 4,4
DATA 04,-1,04,-1
DATA -1,04,04,04
DATA 04,04,04,-1
DATA -1,04,-1,04

'Range power up
DATA 4,4
DATA -1,-1,05,05
DATA -1,05,05,05
DATA 05,05,05,-1
DATA 05,05,-1,-1

'Health power up
DATA 4,4
DATA -1,04,04,-1
DATA 04,15,15,04
DATA 04,15,15,04
DATA -1,04,04,-1

SUB AI (p1XCoor, p1YCoor, p1Angle, p1Attack, p1AttackAreaX, p1AttackAreaY, p2XCoor, p2YCoor, p2Angle, p2Attack, p2AttackAreaX, p2AttackAreaY, p1Distance, p1MoveSpeed, p1TurnSpeed, p1Damage, p1Range, p1Health, p2Distance, p2MoveSpeed, p2TurnSpeed,  _
p2Damage, p2Range, p2Health, powerUp, powerUpType, powerUpX, powerUpY, p2TurnLeft, p2TurnRight, powerUpFlag)
  LET p2TurnLeft = false
  LET p2TurnRight = false
  LET p2Attack = false
  let powerUpFlag = false
 
  LET attackDistance = SQR((p2XCoor - p1AttackAreaX) ^ 2 + (p2YCoor - p1AttackAreaY) ^ 2)
 
  IF p2XCoor <> p1XCoor THEN
      LET playerAngle = ATN((p2YCoor - p1YCoor) / (p2XCoor - p1XCoor))
      IF p2XCoor < p1XCoor THEN
        LET playerAngle = playerAngle + pi
      END IF
    ELSEIF p2YCoor > p1YCoor THEN
      LET playerAngle = pi / 2
    ELSE
      LET playerAngle = 3 * pi / 2
  END IF
  IF playerAngle < 0 THEN
    LET playerAngle = 2 * pi + playerAngle
  END IF
  LET playerAngle = playerAngle - pi / 2
  IF p2YCoor > p1YCoor THEN
      LET playerAngle = -playerAngle
    ELSEIF p2YCoor < p1YCoor THEN
      LET playerAngle = -playerAngle + 2 * pi
  END IF
  IF playerAngle >= 2 * pi THEN
      LET playerAngle =  playerAngle - 2 * pi
    ELSEIF playerAngle < 0 THEN
      LET playerAngle = playerAngle + 2 * pi
  END IF
       
  IF p2XCoor <> powerUpX THEN
      LET powerUpAngle = ATN((p2YCoor - powerUpY) / (p2XCoor - powerUpX))
      IF p2XCoor < powerUpX THEN
        LET powerUpAngle = powerUpAngle + pi
      END IF
    ELSEIF p2YCoor > powerUpY THEN
      LET powerUpAngle = pi / 2
    ELSE
      LET powerUpAngle = 3 * pi / 2
  END IF
  IF powerUpAngle < 0 THEN
    LET powerUpAngle = 2 * pi + powerUpAngle
  END IF
  LET powerUpAngle = powerUpAngle - pi / 2
  IF p2YCoor > powerUpY THEN
      LET powerUpAngle = -powerUpAngle
    ELSEIF p2YCoor < powerUpY THEN
      LET powerUpAngle = -powerUpAngle + 2 * pi
  END IF
  IF powerUpAngle >= 2 * pi THEN
      LET powerUpAngle =  powerUpAngle - 2 * pi
    ELSEIF powerUpAngle < 0 THEN
      LET powerUpAngle = powerUpAngle + 2 * pi
  END IF
 
  IF powerUp = true AND p1Range <= attackDistance  THEN
       IF p2Angle * (pi / 180) > powerUpAngle THEN
           LET p2TurnRight = true
         ELSEIF p2Angle * (pi / 180) < powerUpAngle THEN
           LET p2TurnLeft = true
       END IF
       LET powerUpFlag = true
     ELSE
       LET powerUpFlag = false
       IF attackDistance <= p1Range AND p1Attack = true THEN
           LET p2Attack = false
           IF p2Angle * (pi / 180) > pi - playerAngle THEN
               LET p2TurnRight = true
             ELSEIF p2Angle * (pi / 180) < pi - playerAngle THEN
               LET p2TurnLeft = true
           END IF
         ELSEIF attackDistance > p1Range OR p1Attack = false THEN
           LET p2Attack = true
           IF p2Angle * (pi / 180) > playerAngle THEN
               LET p2TurnRight = true
             ELSEIF p2Angle * (pi / 180) < playerAngle THEN
               LET p2TurnLeft = true
           END IF
       END IF
  END IF
END SUB

SUB drawBackground (outlineColor, bgColor)
  FOR x = 0 TO 320 STEP 20
    LINE (x, 0)-(x, 200), bgColor
  NEXT x

  FOR y = 0 TO 200 STEP 20
    LINE (0, y)-(320, y), bgColor
  NEXT y

  LINE (0, 0)-(319, 0), outlineColor
  LINE (0, 0)-(0, 199), outlineColor
  LINE (319, 199)-(0, 199), outlineColor
  LINE (319, 199)-(319, 0), outlineColor
END SUB

SUB graphicsEngine (graphic(), graphicWidth, graphicHeight, xCoor, yCoor, negAngle)
  LET angle = -negAngle
  LET radians = angle * (pi / 180)
  LET shiftDistance = SQR((xCoor - (xCoor + (graphicWidth / 2))) ^ 2 + (yCoor - (yCoor + (graphicHeight / 2))) ^ 2)
  LET shiftRadians = pi + ATN((((graphicHeight / 2) + yCoor) - yCoor) / (((graphicWidth / 2) + xCoor) - xCoor))
  LET shiftXCoor = xCoor + shiftDistance * COS(radians + (shiftRadians))
  LET shiftYCoor = yCoor + shiftDistance * SIN(radians + (shiftRadians))
  FOR y = shiftYCoor + 1 TO shiftYCoor + graphicHeight
    FOR x = shiftXCoor + 1 TO shiftXCoor + graphicWidth
      IF graphic(x - shiftXCoor, y - shiftYCoor) <> -1 THEN
        LET distance = SQR((x - shiftXCoor) ^ 2 + (y - shiftYCoor) ^ 2)
        LET tRadians = radians + ATN(((y - shiftYCoor) * (pi / 180)) / ((x - shiftXCoor) * (pi / 180)))
        PSET (INT(.5 + (shiftXCoor + (distance * COS(tRadians)))), INT(.5 + shiftYCoor + (distance * SIN(tRadians)))), graphic(x - shiftXCoor, y - shiftYCoor)
      END IF
    NEXT x
  NEXT y
END SUB

SUB graphicsLoader (graphic())
  READ graphicWidth
  READ graphicHeight
  FOR y = 1 TO graphicHeight
    FOR x = 1 TO graphicWidth
      READ graphic(x, y)
    NEXT x
  NEXT y
END SUB

SUB healthBar (x, y, barColor, health)
  LINE (x, y)-(x + 5, y - (health / 2)), barColor, BF
END SUB

FUNCTION keyCheck (keyCode)
   IF MULTIKEY(KeyCode) = -1 THEN
         keyCheck = true
      ELSE
         keyCheck = false
   END IF
END FUNCTION

SUB particle (particleX, particleY, particleLength, particleColor)
  LINE (particleX, particleY)-(particleX + (RND * particleLength * COS(RND * 2 * pi)), particleY + (RND * particleLength * SIN(RND * 2 * pi))), particleColor
  LINE (particleX, particleY)-(particleX + (RND * particleLength * COS(RND * 2 * pi)), particleY + (RND * particleLength * SIN(RND * 2 * pi))), particleColor
  LINE (particleX, particleY)-(particleX + (RND * particleLength * COS(RND * 2 * pi)), particleY + (RND * particleLength * SIN(RND * 2 * pi))), particleColor
END SUB
[/syntax]
Logged

nd remember kids, only you can provoke forest fires!
Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #1 on: April 07, 2005, 08:19:35 PM »

It crashes on me after the game starts. Right after the circle starts moving.  :cry:
Logged
Anonymous
Guest
« Reply #2 on: April 07, 2005, 09:26:34 PM »

me too, unfortunately

invalid page fault
Logged
Jotz
Member
*
Posts: 42


« Reply #3 on: April 07, 2005, 09:54:25 PM »

It worked for me.  It's a pretty good game.  Nice work!
Logged
v3cz0r
I hold this place together
*****
Posts: 924



WWW
« Reply #4 on: April 07, 2005, 11:49:29 PM »

It worked fine in XP with the lastest compiler and gfxlib (i mean, the really lastest :P).

What OS are you guys using? 9x? It could be something with the gfxlib, dunno.
Logged

Dr_Davenstein
Na_th_an
*****
Posts: 2052


« Reply #5 on: April 08, 2005, 12:23:22 AM »

WinMe
DX 9

I wont have to worry about this crap too much longer becasue I'm getting a new PC in a couple of weeks.  Tongue
Logged
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #6 on: April 08, 2005, 07:07:25 AM »

Quote from: "Dr_Davenstein"
WinMe
DX 9

I wont have to worry about this crap too much longer becasue I'm getting a new PC in a couple of weeks.  Tongue


*drools.....

 :wink:
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Anonymous
Guest
« Reply #7 on: April 08, 2005, 07:17:16 AM »

im win98

also couldnt compile some of shiftlynx's demos in the challenege section...
Logged
rdc
Senior Member
**
Posts: 176



WWW
« Reply #8 on: April 08, 2005, 10:04:29 AM »

Nicely done. It is quite a challenge. I think I must be getting too old to play these zippy little games. Smiley
Logged

Rattrapmax6
__/--\__
*****
Posts: 2577



WWW
« Reply #9 on: April 08, 2005, 02:22:56 PM »

Sad I got stuck in the menu, cept looping all the Q's on speed setup...
Logged

Kevin (x.t.r.GRAPHICS)

TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« Reply #10 on: April 08, 2005, 02:31:16 PM »

Could some one upload a compiled version,i want to try this
Logged

url=http://www.sloganizer.net/en/][/url]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!