TGC Codebase Backup



Bumper Pong now with 1 or 2 player mode! by Skeletor

22nd Jun 2004 0:20
Summary

Now with 1 Player and 2 Player Mode!!



Description

The changes I made are quite good. There are bumpers now and if you are playing as the blue paddle and you hit the red bumper the ball will bounce back towards you (vice versa). I have also recently added 1 and 2 player mode so Enjoy!

Visit my newly made website at http://www.angelfire.com/games5/db_games/ leave feedback through my website, sign my guest book, pass my site info to a friend, take my poll and have fun.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `Thanks to the enhanced pong game I was Able to Recreate Bumper Pong with 1 player mode and 2 player mode!!!

sync on
sync rate 40
hide mouse

print "1 Player or 2 Player game?"
wait (1000)
do
if inkey$() = "1" then pls = 1:exit
if inkey$() = "2" then pls = 2:exit
loop
if pls = 1
print "AI difficulty? (1 = Beginner, 2 = Novice, 3 = Expert)"
wait (1000)
do
if inkey$() = "1" then AI=460:exit
if inkey$() = "2" then AI=410:exit
if inkey$() = "3" then AI=360:exit
loop
endif
cls

load image "Player_1.bmp",1
load image "Player_2.bmp",2
load image "ball.bmp",3
load image "right_bumper_3.bmp",5
load image "left_bumper_3.bmp",6

load music "Sphere in space.mid",1

load sound "thump.wav",1
load sound "bounce.wav",2
load sound "dropped.wav",3
load sound "getready.wav",4
load sound "clapping.wav",5

set sound volume 1,100
set sound volume 2,100
set sound volume 3,100
set sound volume 5,100


play music 1
play sound 4

dim player_x(2)
dim player_y(2)
player_x(1) = 30
player_y(1) = 240
player_x(2) = 600
player_y(2) = 240

dim player_score(2)

level = 1

sprite5_y = 50
sprite6_y = 420
sprite5_x = 320
sprite6_x = 280
bumper_speed = 2

sprite5_dir = 1
sprite6_dir = 1

ball_y = 240
ball_x = 400

ball_speed = 7

rnd_direct_x = rnd(1)
rnd_direct_y = rnd(1)

ballx_dir = rnd_direct_x
bally_dir = rnd_direct_y

set text opaque
text 25,1, "Player 1 score: "
text 480,1, "Player 2 score: "
text 260,1, "Bumper Pong"


do
   if keystate(17) = 1 then player_y(1)=player_y(1) - 10
   if keystate(31) = 1 then player_y(1)=player_y(1) + 10

   if pls = 2
   if upkey() = 1 then player_y(2)=player_y(2) - 10
   if downkey() = 1 then player_y(2)=player_y(2) + 10
   endif

   if sprite5_dir = 1 then INC sprite5_y, bumper_speed
   if sprite6_dir = 1 then DEC sprite6_y, bumper_speed

   if sprite5_y < 49 then delete sprite 5 :reset_bumper = 1
   if sprite5_y > 420 then delete sprite 5 :reset_bumper = 1
   if sprite6_y < 50 then delete sprite 6 :reset_bumper = 1
   if sprite6_y > 420 then delete sprite 6 :reset_bumper = 1

   if ballx_dir = 0 then DEC ball_x, ball_speed
   if ballx_dir = 1 then INC ball_x, ball_speed

   if bally_dir = 0 then DEC ball_y, ball_speed
   if bally_dir = 1 then INC ball_y, ball_speed

   if ball_x < 1 then player_score(2) = player_score(2) + 1:Text 480,1, "Player Two's Score: " + STR$(player_Score(2)):set_ball=1:delete sprite 3:play sound 3
   if ball_x > 635 then player_score(1) = player_score(1) + 1:Text 25,1, "Player One's Score: " + STR$(player_Score(1)):set_ball=1:delete sprite 3:play sound 3

   if ball_x < 1 then ball_x = 500 : ball_y = 240 : ballx_dir = 0
   if ball_x > 635 then ball_x = 100 : ball_y = 240 : ballx_dir = 1

   if ball_y < 50 then bally_dir = 1:play sound 1
   if ball_y > 475 then bally_dir = 0:play sound 1

   if pls = 1
   if ball_y < player_y(2) and ball_x > AI then player_y(2) = player_y(2) - 8
   if ball_y > player_y(2) and ball_x > AI then player_y(2) = player_y(2) + 8
   endif

   for check_y_pos = 1 to 2
      if player_y(check_y_pos) < 50 then player_y(check_y_pos) = 50
      if player_y(check_y_pos) > 430 then player_y(check_y_pos)=430
   next check_y_pos

   sprite 1, player_x(1), player_y(1),1
   sprite 2, player_x(2), player_y(2),2
   sprite 3, ball_x, ball_y,3
   sprite 5, sprite5_x, sprite5_y,5
   sprite 6, sprite6_x, sprite6_y,6

   for check_collision = 1 to 2
   if sprite hit(check_collision, 3) = 1
      if check_collision = 1 then ballx_dir = 1:play sound 2
      if check_collision = 2 then ballx_dir = 0:play sound 2
   endif
   next check_collision

   for bumper_collision = 5 to 6
   if sprite hit(bumper_collision, 3) = 1
      if bumper_collision = 5 then ballx_dir = 1:play sound 2
      if bumper_collision = 6 then ballx_dir = 0:play sound 2
   endif
   next bumper_collision

   if reset_bumper = 1
      sprite5_x = 320
      sprite5_y = 50
      sprite6_x = 280
      sprite6_y = 420

      sprite5_dir = 1
      sprite6_dir = 1

      reset_bumper = 0
      endif


   if set_ball = 1
      play sound 4
      sleep 1000

      if player_score(1) = 10 then text 255,280, "Player One Wins!!!": play sound 5 : sleep 2500:end
      if player_score(2) = 10 then text 255,280, "Player Two Wins!!!": play sound 5 : sleep 2500:end

      set_ball = 0
   endif
sync
loop