TGC Codebase Backup



Simple card game by General Sephiro

28th Aug 2005 18:32
Summary

Card Game - Match the Pairs



Description

*see attactchments*



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `*see attactchments for files*

sync on : sync rate 0
`Great Variables
Dim Cards(8,4)
Dim CardsTextured(16)
Dim CardsTurned(16)
Dim CardsSelected(2)
Dim PairFound(8)
GameFinished = 0


`Mini Game 13 / 30 a.k.a. cards
Show Mouse
ink RGB(255,255,255),0
`Main Background - brief include Health and Safety info
make object plain 11000,650,480
load image "MiniGamesCardsBrief.png",1
texture object 11000,1
lock object on 11000
position object 11000,0,0,400
set point light 0,0,0,0
set light range 0,10000
delete image 1

load sound "MiniGames/Sounds/Getready.wav",3
Play sound 3

`Intro to mini-game
While GameFinished = 0
	`If any-key is pressed continue
	If ScanCode() > 0 Then GameFinished = 1
	`If Continue is clicked...
	If MouseX()=>55 and MouseX()=<584
		If MouseY()=>406 and MouseY() <= 430
			If MouseClick()=1
				GameFinished = 1
			endif
		endif
	endif
	sync
endwhile

GameFinished = 0
delete sound 3

load image "MiniGamesCardsBackground.png",1
texture object 11000,1
delete image 1
ink RGB(255,255,255),0
GameFinished = 0
load image "MiniGamesCardsCard1.png",1


For a = 1 to 16
make object plain 11000+a,53,60
lock object on 11000+a
texture object 11000+a,1
next a
delete image 1
`First line *1 to 4*
position object 11001,-208,62,399
position object 11002,-128,62,399
position object 11003,-48,62,399
position object 11004,31,62,399
`Second Line *5 to 10*
Position object 11005,-208,-24,399
Position object 11006,-128,-24,399
Position object 11007,-48,-24,399
Position object 11008,31,-24,399
Position object 11009,110,-22,399
Position object 11010,190,-22,399
`Third line *11 to 16*
Position object 11011,-208,-110,399
Position object 11012,-128,-112,399
Position object 11013,-48,-110,399
Position object 11014,31,-110,399
Position object 11015,111,-110,399
Position object 11016,190,-110,399


load image "MiniGamesCardsCard1.png",1
load image "MiniGamesCardsCard2.png",2
load image "MiniGamesCardsCard3.png",3
load image "MiniGamesCardsCard4.png",4
load image "MiniGamesCardsCard5.png",5
load image "MiniGamesCardsCard6.png",6
load image "MiniGamesCardsCard7.png",7
load image "MiniGamesCardsCard8.png",8
GameFinished = 0
For a = 1 to 8
	`reset cards
	Cards(a,1)=0
	Cards(a,2)=0
next a

For a = 1 to 16
	CardsTextured(a)=0
next a

`Texture first card
While GameFinished = 0
	a = rnd(15)+1
	`If Not alread textured
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(1,1) = a
		texture object 11000+a,1  
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Texture second card
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(1,2) = a
		texture object 11000+a,1
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Third Card
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(2,1) = a
		texture object 11000+a,2 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Forth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(2,2) = a
		texture object 11000+a,2 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Fith Card
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(3,1) = a
		texture object 11000+a,3 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`sixth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(3,2) = a
		texture object 11000+a,3 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`seventh
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(4,1) = a
		texture object 11000+a,4 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Eighth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(4,2) = a
		texture object 11000+a,4 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`Ninth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(5,1) = a
		texture object 11000+a,5 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`tenth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(5,2) = a
		texture object 11000+a,5 
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`elevnth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(6,1) = a
		texture object 11000+a,6
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`twelth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(6,2) = a
		texture object 11000+a,6
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`thirteenth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(7,1) = a
		texture object 11000+a,7
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`fourteenth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(7,2) = a
		texture object 11000+a,7
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`fithteenth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(8,1) = a
		texture object 11000+a,8
		GameFinished = 1
	endif
endwhile
GameFinished = 0

`sixthteenth
While GameFinished = 0
	a = rnd(15)+1
	If CardsTextured(a)=0
		CardsTextured(a)=1
		Cards(8,2) = a
		texture object 11000+a,8
		GameFinished = 1
	endif
endwhile
GameFinished = 0


For a = 1 to 8
	if image exist(a)=1 Then delete image a
next a

`Hide all box's
For a = 11001 to 11020
	If Object exist(a)=1 Then hide object a
next a

`Reset variables
CardsSelected(1) = 0
CardsSelected(2) = 0
selected1 = 0
selected2 = 0
Points4 = 0
NumberCardsFound = 0

`sounds
load sound "MiniGamesSoundsBeep.wav",1
load sound "MiniGamesSoundsClapping.wav",2
Wait 500
For a = 1 to 16
	CardsTurned(a) = 0
next a

while GameFinished= 0 


`If a box is clicked
	`1.) 85,148     139,207
	If MouseX()>85 and MouseX()<139 and MouseY()>148 and MouseY()<207 and MouseClick()=1
		If CardsTurned(1)= 0
			b = 1
			gosub PairFound
		endif
	endif
	
	`2.) 166,148    148,207
	If MouseX()>166 and MouseX()<219 and MouseY()>148 and MouseY()<207 and MouseClick()=1
		If CardsTurned(2)= 0
			b = 2
			gosub PairFound
		endif
	endif
	
	`3) 245,148     299, 207
	If MouseX()>245 and MouseX()<299 and MouseY()>148 and MouseY()<207 and MouseClick()=1
		If CardsTurned(3)= 0
			b = 3
			gosub PairFound
		endif
	endif
	
	`4.) 324,148    378,208
	If MouseX()>324 and MouseX()<378 and MouseY()>148 and MouseY()<207 and MouseClick()=1
		If CardsTurned(4)= 0
			b = 4
			gosub PairFound
		endif
	endif
	
	`5.) 85,235         140,295
	If MouseX()>85 and MouseX()<140 and MouseY()>235 and MouseY()<295 and MouseClick()=1
		If CardsTurned(5)= 0
			b = 5
			gosub PairFound
		endif
	endif
	
	`6.) 165, 235       218,294
	If MouseX()>165 and MouseX()<218 and MouseY()>235 and MouseY()<295 and MouseClick()=1
		If CardsTurned(6)= 0
			b = 6
			gosub PairFound
		endif
	endif
	
	`7.) 245,235       298,294
	If MouseX()>218 and MouseX()<294 and MouseY()>235 and MouseY()<295 and MouseClick()=1
		If CardsTurned(7)= 0
			b = 7
			gosub PairFound
		endif
	endif
	
	`8.) 324, 235   378,294
	If MouseX()>324 and MouseX()<378 and MouseY()>235 and MouseY()<295 and MouseClick()=1
		If CardsTurned(8)= 0
			b = 8
			gosub PairFound
		endif
	endif
	
	`9.) 405,233 and 457,293
	If MouseX()>405 and MouseX()<457 and MouseY()>233 and MouseY()<293 and MouseClick()=1
		If CardsTurned(9)= 0
			b = 9
			gosub PairFound
		endif
	endif
	
	`10.) 484,233       537,292
	If MouseX()>484 and MouseX()<537 and MouseY()>233 and MouseY()<292 and MouseClick()=1
		If CardsTurned(10)= 0
			b = 10
			gosub PairFound
		endif
	endif
	
	`11.) 85,322     138,381
	If MouseX()>85 and MouseX()<138 and MouseY()>322 and MouseY()<381 and MouseClick()=1
		If CardsTurned(11)= 0
			b = 11
			gosub PairFound
		endif
	endif
	
	`12.) 164, 323     218,383
	If MouseX()>164 and MouseX()<218 and MouseY()>328 and MouseY()<383 and MouseClick()=1
		If CardsTurned(12)= 0
			b = 12
			gosub PairFound
		endif
	endif
	
	`13.) 245,321     299,381
	If MouseX()>245 and MouseX()<299 and MouseY()>321 and MouseY()<381 and MouseClick()=1
		If CardsTurned(13)= 0
			b = 13
			gosub PairFound
		endif
	endif
	
	`14.) 324,322     378,380
	If MouseX()>324 and MouseX()<378 and MouseY()>322 and MouseY()<380 and MouseClick()=1
		If CardsTurned(14)= 0
			b = 14
			gosub PairFound
		endif
	endif
	
	`15.) 404,321     457,380
	If MouseX()>404 and MouseX()<457 and MouseY()>321 and MouseY()<380 and MouseClick()=1
		If CardsTurned(15)= 0
			b = 15
			gosub PairFound
		endif
	endif
	
	`16.) 484,321    537,380
	If MouseX()>484 and MouseX()<537 and MouseY()>321 and MouseY()<380 and MouseClick()=1
		If CardsTurned(16)= 0
			b = 16
			gosub PairFound
		endif
	endif

set cursor 490,139
Print Points4
	sync
set cursor 490,139
Print Points4

If NumberCardsFound => 8
				load image "Menus/OK.bmp",25
				make object plain 11020,280,120
				texture object 11020,25
				lock object on 11020
				position object 11020,0,0,399
				delete image 25
				OK = 0
				Wait 100
				INK RGB(0,0,0),0
				Play Sound 2
				While OK = 0
					If Scancode() > 0 then OK = 1
					If MouseX()>287 and MouseX()<329 and MouseY()>270 and MouseY()<298 and MouseClick()=1 Then OK = 1
					Ink RGB(255,255,255),0
					set cursor 490,139
					Print Points4
					Ink RGB(0,0,0),0
					set cursor 203,220
						Print "Congrats you win"
					sync
					Ink RGB(255,255,255),0
					set cursor 490,139
					Print Points4
					Ink RGB(0,0,0),0
					set cursor 203,220
						Print "Congrats you win"
				endwhile
				INK RGB(255,255,255),0
				OK = 0
				If object exist(11020)=1 then delete object 11020
				GameFinished = 1
endif

	`Exit Game
	If MouseX()>54 and MouseX()<584 and MouseY()>405 and MouseY()<430 and MouseClick()=1 Then GameFinished = 1



endwhile

For a = 11000 to 11050
	If Object exist(a)=1 Then delete object a
next a

For a = 1 to 10
	If sound exist(a)=1 then delete sound a
next a

ink RGB(0,0,0),0
`End Game
End

PairFound:
		If CardsSelected(1) = 0
			CardsSelected(1) = b
			Show object 11000 + b
			For a = 1 to 25
				set cursor 490,139
				Print Points4
				sync
			next a
		else 
			If CardsSelected(2) = 0
				CardsSelected(2) = b
				Show object 11000 + b
				Found = 0
				`IF MATCH IS FOUND
				Points4 = Points4 - 1
				For a = 1 to 8
				if Points4 =< 0 Then Points4 = 0
				`Skip a pair if already found
				if PairFound(a)=0
					if CardsSelected(1) = Cards(a,1) 
						if CardsSelected(2) = Cards(a,2)
					 		PairFound(a)=1
							Found = 1
							Points4 = Points4 + 10
						endif
					endif
				endif
				`Skip a pair if already found
				if PairFound(a)=0
					if CardsSelected(1) = Cards(a,2) 
						if CardsSelected(2) = Cards(a,1)
					 		PairFound(a)=1
							Found = 1
							Points4 = Points4 + 10
						endif
					endif
				endif
				next a
				If Found = 0
					For a = 1 to 20
						set cursor 490,139
						Print Points4
						sync
					next a
					Hide Object (CardsSelected(1) + 11000)
					Hide Object (CardsSelected(2) + 11000)
					CardsSelected(1)=0
					CardsSelected(2)=0
				endif
				If Found = 1
					Play Sound 1
					NumberCardsFound = NumberCardsFound + 1
					`Already turned, cannot be turned over again
					CardsTurned(CardsSelected(1))= 1
					CardsTurned(CardsSelected(2))= 1
					`reset hand
					CardsSelected(1)=0
					CardsSelected(2)=0
				endif
				Found = 0
			endif
		endif

return