TGC Codebase Backup



Pong (my version) by zodiac

20th Mar 2006 16:53
Summary

My version of Pong (No Media)



Description

Simply my version as I did not have enough effort to look up the original game. Controls are in the game, and there is no media. This is a 30 minute project so yell at me all you want.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    10:
cls : sync on : sync rate 200 : randomize rnd(200) 

`Programmed by Kevin Forbes
`PONG

set display mode 640, 480, 32
ink rgb(255, 255, 255), 0

`Start-up
hide mouse
set text font "system"
set text size 100
center text 320, 130, "|          PONG           "
center text 580, 340, ".   |"
line 200, 220, 440, 220
set text size 20
line 320, 0, 320, 480
center text 320, 230, "Programmed by Kevin Forbes"
center text 320, 275, "Controls:"
line 240, 290, 400, 290
text 200, 300, "Up/Down Arrows:          Paddle Movement"
text 200, 315, "Right Click:                   End Game"
text 200, 330, "'S' Button:                     Scores"
center text 320, 360, "Press Any Key to Continue"
center text 320, 400, "Press Esc to quit"
set text font "arial"
set text size 12
center text 320, 460, "version 1.2: 1 or 2 player"
suspend for key:cls
set text font "system"
if inkey$()="s" then gosub scores

`Menu
40:
cls
set text size 30
center text 320, 150, "MAIN MENU"
line 240, 190, 400, 190
set text size 20
text 240, 210, "Press 'S' to see High Scores"
text 240, 225, "Press 'G' to start a game"
text 240, 240, "Press 'Q' to return to start-up screen"
text 240, 255, "Press Esc at any time to Quit"
set cursor 315, 300
input ans$
if ans$ = "s" then gosub scores
if ans$ = "g" then goto 30
if ans$ = "q" then goto 10
if ans$ <> "s" and ans$ < "g" and ans$ <> "q" 
	cls : goto 40
endif 

30:
`Variables 
y = rnd(480):x=rnd(640)
something=2:something2=4
ink rgb(255, 255, 255), 0
rx = 2:ry = 2
player1_score = 0
player2_score = 0
20:
cls
input "Choose Difficulty: (easy, medium, hard, impossible)", diff$
if diff$ = "easy" then ai_diff = 3
if diff$ = "medium" then ai_diff = 4
if diff$ = "hard" then ai_diff = 5
if diff$ = "impossible" then ai_diff = 7
if diff$ <> "easy" and diff$ <> "medium" and diff$ <> "hard" and diff$ <> "impossible"
	print "You need to choose a difficulty. Make sure not to include"
	print "spaces or extra characters, and no capital letters."
	wait 3000 : cls : goto 20
endif

`Main loop
do : cls

	set text size 30
	set cursor 300, 10
	print player1_score
	set cursor 335, 10
	print player2_score
	box x-10, y-10, x, y
	


	if x > 620 
		if y >= y3 and y <= (y3+5)
			ry = 7
			something = 1
			something2 = 3
		endif
		if y >= (y3 + 5) and y <= (y3 + 20)
			ry = 5
			something = 1
		endif
		if y >= (y3 + 20) and y <= (y3 + 40)
			something = 1
		endif
		if y >= (y3 + 40) and y <= (y3 + 55)
			ry = 5
			something = 1
		endif
		if y >= (y3 + 55) and y <= (y3 + 70)
			ry = 7
			something = 1
			something2 = 4
		endif
		if y < y3 or y > (y3 + 60)
			x = x + 10
			player1_score = player1_score + 1
			y = rnd(240):x=rnd(320):rx = 4:ry = 4
			wait 500		
		endif
	endif
	if x < 20 
		if y >= y2 and y <= (y2+5)
			ry = 7
			something = 2
			something2 = 3
		endif
		if y >= (y2 + 5) and y <= (y2 + 20)
			ry = 5
			something = 2
		endif
		if y >= (y2 + 20) and y <= (y2 + 40)
			something = 2
		endif
		if y >= (y2 + 40) and y <= (y2 + 55)
			ry = 5
			something = 2
		endif
		if y >= (y2 + 55) and y <= (y2 + 70)
			ry = 7
			something = 2
			something2 = 4
		endif
		if y < y2 or y > (y2 + 60)
			x = x - 10
			player2_score = player2_score + 1
			y = rnd(240)+240:x=rnd(320)+320:rx = 4:ry = 4
			wait 500		
		endif
	endif
	if y > 480 then something2 = 3
	if y < 10 then something2 = 4




	if something = 1 then x = x - rx 
	if something = 2 then x = x + rx
	if something2 = 3 then y = y - ry
	if something2 = 4 then y = y + ry


	box 0, y2, 10, y2+50
	box 620, y3, 630, y3+50
	line 320, 0, 320, 480
	if upkey()=1
		y2 = y2 - 5
		if y2 < 15 then y2 = 15
	endif
	if downkey()=1
		y2 = y2 + 5
		if y2 > 415 then y2 = 415
	endif
	if y < (y3 + 25)
		y3 = y3 - ai_diff
		if y3 < 15 then y3 = 15
	endif
	if y > (y3 + 25)
		y3 = y3 + ai_diff
		if y3 > 415 then y3 = 415
	endif


	if mouseclick()=2
		if diff$ = "easy"
			if hscore < player1_score then hscore = player1_score
		endif
		if diff$ = "medium"
			if hscorem < player1_score then hscorem = player1_score
		endif
		if diff$ = "hard"
			if hscoreh < player1_score then hscoreh = player1_score	
		endif	
		if diff$ = "impossible"
			if hscorei < player1_score then hscorei = player1_score
		endif
		goto 10
	endif
	if inkey$() = "s"
		if diff$ = "easy"
			if hscore < player1_score then hscore = player1_score
		endif
		if diff$ = "medium"
			if hscorem < player1_score then hscorem = player1_score
		endif
		if diff$ = "hard"
			if hscoreh < player1_score then hscoreh = player1_score	
		endif	
		if diff$ = "impossible"
			if hscorei < player1_score then hscorei = player1_score
		endif
		gosub scores
	endif

	if player1_score = 10 or player2_score = 10
		set text size 60
		if player1_score = 10 
			cls 
			center text 320, 200, "YOU WIN!"
			if diff$ = "easy"
				if hscore < player1_score then hscore = player1_score
			endif
			if diff$ = "medium"
				if hscorem < player1_score then hscorem = player1_score
			endif
			if diff$ = "hard"
				if hscoreh < player1_score then hscoreh = player1_score	
			endif	
			if diff$ = "impossible"
				if hscorei < player1_score then hscorei = player1_score
			endif
			wait 3500: goto 10
		endif
		if player2_score = 10
			cls
			center text 320, 200, "YOU LOSE!"
			if diff$ = "easy"
				if hscore < player1_score then hscore = player1_score
			endif
			if diff$ = "medium"
				if hscorem < player1_score then hscorem = player1_score
			endif
			if diff$ = "hard"
				if hscoreh < player1_score then hscoreh = player1_score	
			endif			
			if diff$ = "impossible"
				if hscorei < player1_score then hscorei = player1_score
			endif
			wait 3500: goto 10
		endif
	endif

`Loop
sync : loop

`Subs
scores:
	cls
	set text size 30
	center text 320, 150, "SCORES"
	line 240, 190, 400, 190
	set text size 20
	set cursor 240, 210
	print "High Scores:  easy              ", hscore
	set cursor 240, 225
	print "                       medium         ", hscorem
	set cursor 240, 240
	print "                       hard               ", hscoreh 
	set cursor 240, 255
	print "                       impossible    ", hscorei
	set cursor 210, 380
	print "Press Any Key to Return to Title Screen":wait 1000
	suspend for key:cls
	goto 10
return