Missing Type Specifier

BlitzMax Forums/BlitzMax Beginners Area/Missing Type Specifier

Blitzogger(Posted 2006) [#1]
I get the error "Missing Type Specifier in function CleanUP() which means i don't have TImage. However Function LoadSprites() is where the image handles are being specified. All Function CleanUp() does is remove all the game references from memory to conserve it. Do i have to declare my image handlers again to destroy them?

Code Broken



Luke.H(Posted 2006) [#2]
I cannot run your code but I think you need to declare the global object outside the function, or it is just a static object

Look at:


a=8

Test()

Print a


Function Test()
Global a=3

End Function



and



Global a


a=8

Test()

Print a


Function Test()
	a=3
	
End Function




or even



Global a

a=8

Test()

Print a


Function Test()
Global a=3

End Function




(I got too much freetime)


Blitzogger(Posted 2006) [#3]
I thought Global meant it could be run anywhere?

Local:
http://www.blitzbasic.com/bpdocs/command.php?name=Global&ref=2d_a-z
http://www.blitzwiki.org/index.php/Local

Global:
http://www.blitzbasic.com/bpdocs/command.php?name=Local&ref=2d_a-z
http://www.blitzwiki.org/index.php/Global


degac(Posted 2006) [#4]
If a GLOBAL variable is defined IN a function, this means that variabile keeps its value intact for the next call, but OUTSIDE of this function it can not be 'viewed'.
In your case you want to access to the variabile in every place of your program, so you need to define global externally to any function.
Sorry for my bad english...it's early morning...
byez


Blitzogger(Posted 2006) [#5]
I fixed up code a bit including a few strings i forgot to include in the Load Image Code. I had
and Function CleanUp missing (). Now i get this error:

Compile Error: Identifier 'Ball_Image' not found

Code Being Fixed



Luke.H(Posted 2006) [#6]
Your Code:


Function LoadSprites()
'Load Graphics
Global Ball_Image:TImage = LoadImage("Incbin::Sprites/ball.bmp")		' Ball
Global Player1_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Bat
Global Player2_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Bat
End Function



Try:


Global Ball_Image:TImage
Global Player1_Image:TImage
Global Player2_Image:TImage

Function LoadSprites()
'Load Graphics
Ball_Image:TImage = LoadImage("Incbin::Sprites/ball.bmp")		' Ball
Player1_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Bat
Player2_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Bat
End Function



You have the same problem in other functions too.


Blitzogger(Posted 2006) [#7]
Why is it i have to do this? Also if i make that Global to the entire program and run Function CleanUp() will i be able to call Function LoadSprites() and recreate the variables or will i get a runtime error?


Luke.H(Posted 2006) [#8]
I would say yes, you can, but I cannot see your code


Dreamora(Posted 2006) [#9]
Because a global within a function is not known outside the function so loading anything in a function that is never used again makes no sense ...


Blitzogger(Posted 2006) [#10]
I want to use as little memory as possible so i want to load all my images and stuff only when the game is started. Then after the game ends everything is removed from memory. If the user wants to play again all, the sprites, sounds and variables are loaded again. This is so the game uses as little memory as possible. Also because every part of my game will be controlled from a function, if i want to add additional modes latter, i can just create another function for that game mode and simply use the excisting functions for the main portion and simply create another function for the mod.

Function TwoPlayersGame()
'Setup the Variables
Global Player1:Player = New Player
Global Player2:Player = New Player
Global Ball:Ball = New Ball

'Load Graphics
LoadSprites()

'Load Sounds
LoadSounds()

'Setup a Loop Variable
Local check:Int = 1

'Open A Game Window
Local GWindow:TGadget = CreateWindow( "Pong Master - 2 Player", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-165, 480, 640 )
Local GraphicsWindow:TGadget=CreateCanvas(10,10,480,640,GWindow)
ShowGadget GWindow


While check = 1
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (GraphicsWindow)
	MoveBall()
	BallBouncing()    
	Player1Movement()
	Player2Movement()
	PositionObjects()
    TrackScores()
	Flip
   End Select
Wend

FreeGadget GWindow
FreeGadget GraphicsWindow

'The game is finished so cleanup
CleanUp()
End Function


And the One Player Game Code
Function OnePlayersGame()
'Setup the Variables
Global Player1:Player = New Player
Global Player2:Player = New Player
Global Ball:Ball = New Ball

'Load Graphics
LoadSprites()

'Load Sounds
LoadSounds()

'Setup a Loop Variable
Local check:Int = 1

'Open A Game Window
Local GWindow:TGadget = CreateWindow( "Pong Master - 2 Player", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-165, 480, 640 )
Local GraphicsWindow:TGadget=CreateCanvas(10,10,480,640,GWindow)
ShowGadget GWindow


While check = 1
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (GraphicsWindow)
	MoveBall()
	BallBouncing()    
	Player1Movement()
	ComputerAI()
	PositionObjects()
    TrackScores()
	Flip
   End Select
Wend

FreeGadget GWindow
FreeGadget GraphicsWindow

'The game is finished so cleanup
CleanUp()
End Function


Mount-A-ComeBack Minigame code:
Function MountAComebackGame()
'Setup the Variables
Global Player1:Player = New Player
Global Player2:Player = New Player
Global Ball:Ball = New Ball

Player1.Score = 13
Player2.Score = 14

'Load Graphics
LoadSprites()

'Load Sounds
LoadSounds()

'Setup a Loop Variable
Local check:Int = 1

'Open A Game Window
Local GWindow:TGadget = CreateWindow( "Pong Master - 2 Player", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-165, 480, 640 )
Local GraphicsWindow:TGadget=CreateCanvas(10,10,480,640,GWindow)
ShowGadget GWindow


While check = 1
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (GraphicsWindow)
	MoveBall()
	BallBouncing()    
	Player1Movement()
	ComputerAI()
	PositionObjects()
    TrackScores()
	Flip
   End Select
Wend

FreeGadget GWindow
FreeGadget GraphicsWindow

'The game is finished so cleanup
CleanUp()
End Function


Does everyone understand me a little better now?

Ok, for some reason this is giving my a Missing Type Specificer Error, even though i added it to the top of my program which should make it global.
fixing



skidracer(Posted 2006) [#11]
You need to take out the Global declarations in your LoadSounds and LoadSprites functions as they are confusingly creating new variables that are in fact static and hence the global variables declared at the top of your code are remaining unchanged, or as in your case causing compiler errors.


Blitzogger(Posted 2006) [#12]
Ok, i added the player movement code. However when i try it out nothing happens. I have flip at the end of my loop. Also SetBuffer BackBuffer no longer works. I have the Gadget Repaint Event in my loop. Any ideas?

fixing



Luke.H(Posted 2006) [#13]
KeyDown, KeyUp, etc. will not work if graphics is not set, but you can get input from the event queue (But I have not used the GUI very much)

SetBuffer BackBuffer is also using graphics.


You also need a timer, e.g.

Local timer:TTimer = CreateTimer (60)

<AND>

Case EVENT_TIMERTICK
RedrawGadget GraphicsWindow


Have you made pong without a GUI because what you are doing is WAY harder then it needs to be.


Blitzogger(Posted 2006) [#14]
Indentified TTimer not found.


Dreamora(Posted 2006) [#15]
You are missing the needed module for timers

I wouldn't use frameworks until you release the program to prevent this kind of problem.


Blitzogger(Posted 2006) [#16]
Nope nothing happened when i added that.

not longer in use


I wanted to create my game using GUIs since it looks nicer then just a black screen and the game immediately starting. I wanted to add the ability to give instructions and stuff. The main problem stems in the fact that graphics no longer has a windowed mode. Wizard Wars in BlitzPlus did this easily, so why am i having problems trying to do it BlitzMAX?

P.S. No i have never made Pong. This is my first time.


Luke.H(Posted 2006) [#17]
You should try and split your code in to a GUI part and a game part, why not make pong without a GUI first?

Anyway, like I said Keydown is not working in you code, the GUI is blocking it (or because you have not used Graphics), I think you need to get it as an event, and then maybe store it in a global

Also BlitzMax will load all the libraries if you take out framework and the import commands, and you can put framework back it when you know what you will need.


Blitzogger(Posted 2006) [#18]
Alright i'll do the entire thing from start. I'm having problems too though. The command Text doesn't seem to excist.

Text 0,0, "Hi"


Compile Error: Identifier 'Text' not found



Dreamora(Posted 2006) [#19]
DrawText (see the Max2D documentation for further commands)


Blitzogger(Posted 2006) [#20]
This code doesn't work and causes the application to freeze. Additionally the DrawText command doesn't work. My loop is not endless so why is it freezing up?

'Pong Master v0.1
'Copyright c2005 Dark Mars Software
'written by Dark Mars Software

'Option Explicit
SuperStrict

'Load Libraries

'Include the Media Files
IncludeMedia()

'Open a Game Window
Graphics 480,640, 0

'Define the Applications Title
AppTitle = "Pong Master 0.1"

'Define Global Variables
'Sprite Variables
Global Player_Image:Timage	'Player's Bat
Global Ball_Image:Timage		'Ball


'Sound Variables
Global Applause_Sound:TSound	' Applause
Global Boink1_Sound:TSound 	' Boink 1
Global Boink2_Sound:TSound		' Boink 2
Global Explosion_Sound:TSound  ' Explosion

'Player Type
Type Player
	Field X_Position:Int,Score:Int
End Type

Global Player1:Player = New Player

Global Player2:Player = New Player

Type Ball
	Field X_Position:Int,Y_Position:Int,X_Velocity:Int,Y_Velocity:Int
End Type

Global Balls:Ball = New Ball

TitleScreen()

Function BallBouncing()

End Function

Function CleanUp()
'Remove Graphics
Ball_Image = Null		'Ball
Player_Image = Null	'Player's Bat

'Remove Sounds
Applause_Sound = Null	' Applause
Boink1_Sound = Null 	' Boink 1
Boink2_Sound = Null		' Boink 2
Explosion_Sound = Null  ' Explosion
End Function

Function IncludeMedia()
'Load Sounds
Incbin "Sounds/applause.wav"		' Applause
Incbin "Sounds/boink1.wav"		    ' Boink 1
Incbin "Sounds/boink2.wav"			' Boink 2
Incbin "Sounds/explosion.wav"		' Explosion

'Load Graphics
Incbin "Sprites/ball.bmp"			' Ball
Incbin "Sprites/bat.bmp"			' Bat
End Function

Function LoadSounds()
'Load Sounds
Applause_Sound:TSound = LoadSound("Incbin::Sounds/applause.wav")		' Applause
Boink1_Sound:TSound = LoadSound("Incbin::Sounds/boink1.wav")			' Boink 1
Boink2_Sound:TSound = LoadSound("Incbin::Sounds/boink2.wav")			' Boink 2
Explosion_Sound:TSound = LoadSound("Incbin::Sounds/explosion.wav")	' Explosion
End Function

Function LoadSprites()
'Load Graphics
Ball_Image:TImage = LoadImage("Incbin::Sprites/ball.bmp")		' Ball
Player_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Players Bat
End Function

Function MoveBall()

End Function

Function Player1Movement()
If KeyDown(KEY_LEFT) Then Player1.X_Position = Player1.X_Position + 5
If KeyDown(KEY_RIGHT) Then Player1.X_Position = Player1.X_Position - 5
End Function

Function Player2Movement()
If KeyDown(KEY_A) Then Player2.X_Position = Player2.X_Position + 5
If KeyDown(KEY_S) Then Player2.X_Position = Player2.X_Position - 5
End Function

Function PositionObjects()
DrawImage(Player_Image, Player1.X_Position, 50)
DrawImage(Player_Image, Player2.X_Position, 560)
DrawImage(Ball_Image, Balls.X_Position, Balls.Y_Position)
End Function

Function ResetLevel()
Player1.X_Position = 240
Player2.X_Position = 240
Balls.X_Position = 240
Balls.Y_Position = 320
End Function

Function TitleScreen()
Local response:String
While response <> "1" Or response <> "Q"
Cls
DrawText "Press 1 to Play", 200, 300
DrawText "Press Q To Quit", 200, 350
Input response
Wend
End Function

Function TrackScores()

End Function

Function TwoPlayersGame()
'Load Graphics
LoadSprites()

'Load Sounds
LoadSounds()

'Setup a Loop Variable
Local check:Int = 1

'Setup the Level
ResetLevel()

While check = 1
	MoveBall()
	BallBouncing()    
	Player1Movement()
	Player2Movement()
	PositionObjects()
    TrackScores()
	Flip
Wend

'The game is finished so cleanup
CleanUp()
End Function



Luke.H(Posted 2006) [#21]
Try this:




Blitzogger(Posted 2006) [#22]
Unhandled Exception:Attempt to access field or method of Null object.

Now i'll never be able to sell it because its not my code!

You know what i'm thinking of just leaving this community for awhile to relax. I don't like BlitzMAX too much. Its more difficult when compared to BlitzPlus. No offence but, i just need time to relax. Thats not to say that i woun't return.


REDi(Posted 2006) [#23]
Did you uncomment the the Incbins and load functions?


Blitzogger(Posted 2006) [#24]
No, but i'm gonna give this a rest and work on it in another language for now. I m ight return soon.


Luke.H(Posted 2006) [#25]
Dark Mars Software:
Your free to use the code for what ever you like,
BlitzMax is not that difficult, I was just showing you some new stuff you CAN do in blitzmax, you can just use the old stuff too if you like.

And like Papa Lazarou said "did you uncomment the the Incbins and load functions?"


Blitzogger(Posted 2006) [#26]
'Pong Master v0.1
'Copyright c2005 Dark Mars Software
'written by Dark Mars Software

'Option Explicit
SuperStrict

'Load Libraries
'Framework BRL.D3D7Max2D
'Import BRL.System
'Import BRL.RamStream
'Import BRL.WAVLoader
'Import BRL.BMPLoader
'Import BRL.Win32MaxGUI
'Import BRL.FreeAudioAudio
'Import BRL.Timer

' modules which may be required:
' Import BRL.PNGLoader
' Import BRL.TGALoader
' Import BRL.JPGLoader
' Import BRL.OGGLoader


SetGraphicsDriver D3D7Max2DDriver()

'Include the Media Files
IncludeMedia()

'Define the Applications Title
AppTitle = "Pong Master 0.1"

'Define Global Variables
'Sprite Variables
Global Player_Image:Timage	'Player's Bat
Global Ball_Image:Timage		'Ball


'Sound Variables
Global Applause_Sound:TSound	' Applause
Global Boink1_Sound:TSound 	' Boink 1
Global Boink2_Sound:TSound		' Boink 2
Global Explosion_Sound:TSound  ' Explosion

'Player Type
Type Player
	Field X_Position:Int,Score:Int
End Type

Global Player1:Player = New Player

Global Player2:Player = New Player

Type Ball
	Field X_Position:Int,Y_Position:Int,X_Velocity:Int,Y_Velocity:Int
End Type

Global Balls:Ball = New Ball

TitleScreen()

Function BallBouncing()

End Function

Function CleanUp()
'Remove Graphics
Ball_Image = Null		'Ball
Player_Image = Null	'Player's Bat

'Remove Sounds
Applause_Sound = Null	' Applause
Boink1_Sound = Null 	' Boink 1
Boink2_Sound = Null		' Boink 2
Explosion_Sound = Null  ' Explosion
End Function

Function Credits()
	Local Notif:String=""

	Notif = "Pong Master" + Chr$(10)
	Notif = Notif + "Copyright c2005 Dark Mars Software" + Chr$(10)
	Notif = Notif + "" + Chr$(10)
	Notif = Notif + "Written by" + Chr$(10)
	Notif = Notif + "Dark Mars Software" + Chr$(10)
	Notif = Notif + "" + Chr$(10)
	Notif = Notif + "Ideas by" + Chr$(10)
	Notif = Notif + "Dark Mars Software" + Chr$(10)
	Notif = Notif + "" + Chr$(10)
	Notif = Notif + "Tested by" + Chr$(10)
	Notif = Notif + "Dark Mars Software" + Chr$(10)
	Notif = Notif + "BlitzBASIC Community" + Chr$(10)

	Notify Notif$
End Function

Function IncludeMedia()
'Load Sounds
Incbin "Sounds/applause.wav"		' Applause
Incbin "Sounds/boink1.wav"		    ' Boink 1
Incbin "Sounds/boink2.wav"			' Boink 2
Incbin "Sounds/explosion.wav"		' Explosion

'Load Graphics
Incbin "Sprites/ball.bmp"			' Ball
Incbin "Sprites/bat.bmp"			' Bat
End Function

Function Instructions()
	'create all the required buttons
	Local IWindow:TGadget=CreateWindow( "Instructions", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-230, 210, 460 )
	Local AimButton:TGadget = CreateButton( "Aim of the game", 0, 0, 200, 40, IWindow )
	Local ControlsButton:TGadget = CreateButton( "Controls", 0, 40, 200, 40, IWindow )
	Local RequirementsButton:TGadget = CreateButton( "SystemRequirements", 0, 80, 200, 40, IWindow )
	Local HintsButton:TGadget = CreateButton( "Helpful hints", 0, 120, 200, 40, IWindow )

	Local BackButton:TGadget = CreateButton( "Back", 0, 350, 200, 40, IWindow )
	Local check:Int=1
	
	ShowGadget IWindow

	While check=1
		WaitEvent()
		Select EventID() 'see what gadget has been clicked on
					'if the window close button was clicked on end program
					Case EVENT_WINDOWCLOSE
					 End
					'if the user clicked on a button
					Case EVENT_GADGETACTION
					Select EventSource()
					Case AimButton
					InstructAim()
					Case ControlsButton
					InstructControls()
					Case RequirementsButton
					InstructRequirements()
					Case HintsButton
					InstructTips()
					Case BackButton
					check=0
					End Select
		End Select
	Wend

	'a little house cleaning to make sure the memory is released back to blitz for later use
	'this just frees all the local gadgets that were created at the beginning of this functions
	FreeGadget AimButton
	FreeGadget ControlsButton
	FreeGadget RequirementsButton
	FreeGadget HintsButton
	FreeGadget BackButton
	FreeGadget IWindow

End Function

Function InstructAim()
	Local Notif:String = ""
	
	Notif$ = Notif$ + "Aim of the game" + Chr$(10)
	Notif$ = Notif$ + "-------------------" + Chr$(10)
	Notif$ = Notif$ + "The aim of Pong Master is to score 15 points first by getting the" + Chr$(10)
	Notif$ = Notif$ + " ball past the other players paddle" + Chr$( 10 )
	Notify Notif	
End Function

Function InstructControls()
	Local Notif:String=""

	Notif = Notif + "Player 1 Controls" + Chr$(10)
	Notif = Notif + "---------------------" + Chr$(10)
	Notif = Notif + "Left Arrow Key - Move Paddle Left" + Chr$(10)
	Notif = Notif + "Right Arrow Key - Move Paddle Right" + Chr$(10)
	Notif = Notif + "" + Chr$(10)
	Notif = Notif + "Player 2 Controls" + Chr$(10)
	Notif = Notif + "-----------------" + Chr$(10)
	Notif = Notif + "A - Move Paddle Left" + Chr$(10)
	Notif = Notif + "S - Move Paddle Right" + Chr$(10)
	Notify Notif
End Function



Function InstructRequirements()
	Local Notif:String=""
	
	Notif = Notif + "Requirements" + Chr$(10)
	Notif = Notif + "-----------------" + Chr$(10)
	Notif = Notif + "The minimum spec machines we could test it on is as follows:" + Chr$(10)
	Notif = Notif + "Intel 233MMX" + Chr$(10)
	Notif = Notif + "64Mb Ram (also 32Mb)" + Chr$(10)
	Notif = Notif + "2Mb Harddisk space" + Chr$(10)
	Notif = Notif + "Voodoo 2 and S3 Virge video cards" + Chr$(10)
	Notif = Notif + "IMPORTANT PLEASE READ: Some of the larger maps will require" + Chr$(10)
	Notif = Notif + "more memory, for the small maps 32Mb should suffice but for" + Chr$(10)
	Notif = Notif + "medium to large maps I would recommend 64Mb-128Mb of ram." + Chr$(10)
	Notif = Notif + "We have had reports of unexpected result from running the game" + Chr$(10)
	Notif = Notif + "with insufficient memory." + Chr$(10)
	Notify Notif
End Function

Function InstructTips()
	Local Notif:String=""

	Notif = Notif + "Helpful Tips" + Chr$(10)
	Notif = Notif + "--------------" + Chr$(10)
	Notif = Notif + "Always follow the ball, doing so will allow you" + Chr$(10)
	Notif = Notif + "enough time to possition your paddle accordingly" + Chr$(10)
	Notif = Notif + "" + Chr$(10)
	Notif = Notif + "Learning the balls bounce angle will allow you" + Chr$(10)
	Notif = Notif + "estimate the balls projected path" + Chr$(10)
	Notify Notif
End Function

Function LoadSounds()
'Load Sounds
Applause_Sound:TSound = LoadSound("Incbin::Sounds/applause.wav")		' Applause
Boink1_Sound:TSound = LoadSound("Incbin::Sounds/boink1.wav")			' Boink 1
Boink2_Sound:TSound = LoadSound("Incbin::Sounds/boink2.wav")			' Boink 2
Explosion_Sound:TSound = LoadSound("Incbin::Sounds/explosion.wav")	' Explosion
End Function

Function LoadSprites()
'Load Graphics
Ball_Image:TImage = LoadImage("Incbin::Sprites/ball.bmp")		' Ball
Player_Image:TImage = LoadImage("Incbin::Sprites/bat.bmp")		' Players Bat
End Function

Function MoveBall()

End Function

Function Player1Movement()
If KeyDown(KEY_LEFT) Then Player1.X_Position = Player1.X_Position + 5
If KeyDown(KEY_RIGHT) Then Player1.X_Position = Player1.X_Position - 5
End Function

Function Player2Movement()
If KeyDown(KEY_A) Then Player2.X_Position = Player2.X_Position + 5
If KeyDown(KEY_S) Then Player2.X_Position = Player2.X_Position - 5
End Function

Function PositionObjects()
DrawImage(Player_Image, Player1.X_Position, 50)
DrawImage(Player_Image, Player2.X_Position, 560)
DrawImage(Ball_Image, Balls.X_Position, Balls.Y_Position)
End Function

Function ResetLevel()
Player1.X_Position = 240
Player2.X_Position = 240
Balls.X_Position = 240
Balls.Y_Position = 320
End Function

'starting sequence for system (included Title menu system)
Function TitleScreen()
	'create all the buttons
	Local TWindow:TGadget = CreateWindow( "Main Menu", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-165, 210, 330 )
	Local TwoPlayersButton:TGadget = CreateButton( "2 Player Game", 0, 0, 200, 40, TWindow )
	Local CreditsButton:TGadget = CreateButton( "Credits", 0, 40, 200, 40, TWindow )
	Local InstructionsButton:TGadget = CreateButton( "Instructions", 0, 80, 200, 40, TWindow )
	Local QuitButton:TGadget = CreateButton( "Quit", 0, 120, 200, 40, TWindow )

	ShowGadget TWindow
	
	Local check:Int=1

	While check=1
		WaitEvent()
		Select EventID() 'check To see what gadget has been clicked on
		'if the window close button was clicked on end program
		Case EVENT_WINDOWCLOSE
		End
		'if a button was clicked on
		Case EVENT_GADGETACTION
		'see what gadget has been clicked on
		Select EventSource()
		Case TwoPlayersButton
		check=1
		TwoPlayersGame()
		Case CreditsButton
		Credits()
		Case InstructionsButton
		Instructions()
		Case QuitButton
		End
		End Select
	End Select
	Wend

	FreeGadget TwoPlayersButton
	FreeGadget CreditsButton
	FreeGadget InstructionsButton
	FreeGadget QuitButton
	FreeGadget TWindow

End Function

Function TrackScores()

End Function

Function TwoPlayersGame()
'Load Graphics
LoadSprites()

'Load Sounds
LoadSounds()

'Setup a Loop Variable
Local check:Int = 1
Local timer:TTimer = CreateTimer(60)

'Open A Game Window
Local GWindow:TGadget = CreateWindow( "Pong Master - 2 Player", ( ClientWidth( Desktop() )/2 )-105, ( ClientHeight( Desktop() )/2 )-165, 480, 640, Null, WINDOW_TITLEBAR )
Local GraphicsWindow:TGadget=CreateCanvas(0,0,480,640,GWindow)
ShowGadget GWindow

'Setup the Level
ResetLevel()

While check = 1
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_TIMERTICK
	RedrawGadget GraphicsWindow
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (GraphicsWindow)
	MoveBall()
	BallBouncing()    
	Player1Movement()
	Player2Movement()
	PositionObjects()
    TrackScores()
	Flip   
	End Select
Wend

FreeGadget GWindow
FreeGadget GraphicsWindow

'The game is finished so cleanup
CleanUp()
End Function


Memory Exception Error, Any ideas?


Luke.H(Posted 2006) [#27]
Memory Exception Error?

Have you got a line number, is debug on?