Page 1 of 4
Pong Master - WIP Error Help?
Posted: Fri Jan 06, 2006 10:36 pm
by Dark Mars Software
I have the following sample code after the game loop, end, and freeing code:
The compiler complains with the following error:
[COMPILER]Line 17:LoadVariables() is not a function, an array, or linked list.
Please assist.
Sincerely,
Dark Mars Software
Posted: Fri Jan 06, 2006 10:47 pm
by Straker
either Declare your function before you call it or move the Procedure code above the line where you call it.
Please see Declare in the help file.
Posted: Fri Jan 06, 2006 11:06 pm
by Dark Mars Software
Ok, fixed. Now i have a new problem. Heres the message i get:
[ERROR]Invalid Memory Access.
The code its referencing:
Any ideas?
Posted: Fri Jan 06, 2006 11:45 pm
by blueznl
perhaps a corrupt sound flle?
Posted: Fri Jan 06, 2006 11:50 pm
by Dark Mars Software
K, i added the following code:
Initilizing stages
Then i added the changed the LoadSounds Procedure as follows:
BEFORE:
AFTER:
And that worked. Most like the fact that my sound card doesn't work. Anyways now i get a new error:
#Sprite Object not initalized
And references this code:
However the sprites are loaded in this Procedure:
And the Sprite Enviroment is being initalized in the beginning with:
Help,
Dark Mars Software
Posted: Sat Jan 07, 2006 4:01 am
by netmaestro
You need a delay in the code to prevent using the whole cpu.
Posted: Sat Jan 07, 2006 9:39 am
by dagcrack
...God gave you the IF statement; USE IT.
Hence, whenever you're going to load something, check that it is actually loadable, that at least it's there.
Lazy programmers goes no where!, lazy programming wont go any further. Therefore stick that to your mind, checks are good, not bad.

Posted: Mon Jan 09, 2006 3:05 am
by Dark Mars Software
New Problem:
Code: Select all
Procedure LoadSprites()
LoadSprite(0, "Sprite\bat.bmp", 0)
If IsSprite(0) = 0
MessageRequester("Error", "Can't open Sprite\bat.bmp", 0)
EndIf
player_1_position = 320
CopySprite(0, 1, 0)
player_2_position = 320
LoadSprite(2, "Sprite\ball.bmp", 0)
If IsSprite(2) = 0
MessageRequester("Error", "Can't open Sprite\ball.bmp", 0)
EndIf
ball_x_position = 320
ball_y_position = 240
EndProcedure
Procedure LoadVariables()
;initalize player 1's variables
Global player_1_position.w
Global player_1_score.w
;initalize player 1's variables
Global player_2_position.w
Global player_2_score.w
;initalize ball's variables
Global ball_x_position.w
Global ball_y_position.w
EndProcedure
Procedure Player1Movement()
;check for keyboard input
ExamineKeyboard()
;if player 1 presses left
If KeyboardPushed(#PB_Key_Left)
player_1_position - 5
EndIf
;if player 1 presses right
If KeyboardPushed(#PB_Key_Right)
player_1_position + 5
EndIf
PositionObjects()
EndProcedure
Procedure Player2Movement()
;check for keyboard input
ExamineKeyboard()
;if player 2 presses left
If KeyboardPushed(#PB_Key_A)
player_2_position - 5
EndIf
;if player 2 presses right
If KeyboardPushed(#PB_Key_S)
player_2_position + 5
EndIf
PositionObjects()
EndProcedure
Procedure PositionObjects()
ClearScreen(0, 0, 0)
DisplaySprite(0, player_1_position, 15)
DisplaySprite(1, player_2_position, 450)
DisplaySprite(2, ball_x_position, ball_y_position)
EndProcedure
;ExecutableFormat=Windows
;Executable=C:\Projects\Pong Master - Pure BASIC\Pong Master.exe
;EOF
No matter what i set player_1_position and player_2_position to equal to, the sprites keep appearing on the edge of the screen when the game first loads. Any ideas?
Posted: Mon Jan 09, 2006 4:50 am
by netmaestro
I see a bunch of procedures there, but I don't see where you're calling them. Is this all the code? I wouldn't expect this to do anything. Also, the variables used to store the sprite positions in shouldn't be type .word, they should be type .long
Posted: Mon Jan 09, 2006 3:16 pm
by Dark Mars Software
netmaestro wrote:I see a bunch of procedures there, but I don't see where you're calling them. Is this all the code? I wouldn't expect this to do anything. Also, the variables used to store the sprite positions in shouldn't be type .word, they should be type .long
This is called in the game loop.
Code: Select all
Repeat
Procedure1()
Procedure2()
Procedure3()
...
Until KeyboardPushed(#PB_Key_Escape)
When i try the player movement procedures the paddles move which means this code works. However like i said at startup the paddles aren't put into their proper possitions. Why would i use long instead of word? Long uses more memory and is unnessessary as it holds the sprites screen position. Since the screen itself is being created at 640 * 480, long is large enough to hold the max 680.
Posted: Wed Jan 11, 2006 5:56 pm
by Dark Mars Software
Anyone wanna help me out?
I keep getting the can't open screen clause.
Posted: Wed Jan 11, 2006 6:32 pm
by Fred
if you want to open a windowed screen, you have to attach it to a window. Did you activate the debugger ?
Posted: Wed Jan 11, 2006 6:35 pm
by Dark Mars Software
I don't quite understand what you mean. I looked this up in the reference and there was no mention to this. How do you do this?
Posted: Wed Jan 11, 2006 7:38 pm
by netmaestro
He means if the debugger is turned on when you run the code it will tell you where the errors are.
Posted: Wed Jan 11, 2006 7:55 pm
by Dark Mars Software
Yes a and s control player 2 and left and right control player 1. I added the code you said. Now it keeps failing the If IsSprite(#) = 0 cause. I don't know why since when i ran it under openscreen() i had no problems.
Here is the modifed code: