Pong Master - WIP Error Help?

Just starting out? Need help? Post your questions and find answers here.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Pong Master - WIP Error Help?

Post by Dark Mars Software »

I have the following sample code after the game loop, end, and freeing code:

Code: Select all

solved
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
Last edited by Dark Mars Software on Mon Jan 09, 2006 3:06 am, edited 2 times in total.
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post 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.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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:

Code: Select all

solved
Any ideas?
Last edited by Dark Mars Software on Mon Jan 09, 2006 3:06 am, edited 1 time in total.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

perhaps a corrupt sound flle?
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

K, i added the following code:

Initilizing stages

Code: Select all

solved
Then i added the changed the LoadSounds Procedure as follows:
BEFORE:

Code: Select all

solved
AFTER:

Code: Select all

solved
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:

Code: Select all

solved
However the sprites are loaded in this Procedure:

Code: Select all

solved
And the Sprite Enviroment is being initalized in the beginning with:

Code: Select all

solved
Help,

Dark Mars Software
Last edited by Dark Mars Software on Mon Jan 09, 2006 3:07 am, edited 1 time in total.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

You need a delay in the code to prevent using the whole cpu.
Last edited by netmaestro on Tue Feb 21, 2006 6:34 pm, edited 4 times in total.
BERESHEIT
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post 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.


:)
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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
Last edited by netmaestro on Tue Feb 21, 2006 6:34 pm, edited 2 times in total.
BERESHEIT
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Anyone wanna help me out?

Code: Select all

solved
I keep getting the can't open screen clause.
Last edited by Dark Mars Software on Wed Jan 11, 2006 7:56 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18406
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

if you want to open a windowed screen, you have to attach it to a window. Did you activate the debugger ?
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

He means if the debugger is turned on when you run the code it will tell you where the errors are.
Last edited by netmaestro on Tue Feb 21, 2006 6:36 pm, edited 2 times in total.
BERESHEIT
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post 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:

Code: Select all

solved
Last edited by Dark Mars Software on Wed Jan 11, 2006 9:21 pm, edited 1 time in total.
Post Reply