Pong Master - WIP Error Help?

Just starting out? Need help? Post your questions and find answers here.
Fred
Administrator
Administrator
Posts: 18406
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you have to pass WindowID(0) as first parameter of OpenWindowScreen() else it won't work. You can also use the search function of this forum to see how use OpenWindowedScreen(). For example this one show it:

viewtopic.php?t=18473&highlight=openwindowedscreen
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 fixed up the code abit. However i now notice that my game runs awfully slow. When the game loads i get a hourglass the whole time the game runs. When i click the window the game freezes up and i have to click end program to kill it. Also the sprites not being positioned correctly bug still excists. Heres the modified code:

Code: Select all

solved
I looked in my task manager and my game consumes 39% of my cpu resources! Yikes. No, i don't have the debugger enabled.

EDIT:Adding SetFrameRate(30) before the start of the loop only increased the cpu usage to 80% as opposed to decreasing it like it should.
Last edited by Dark Mars Software on Thu Jan 12, 2006 12:38 am, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18406
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you have to manage the event loop. Remove the delay(1) and put this instead:

Code: Select all

Repeat
  event = windowEvent()
  If Event = 0
    Delay(10)
  EndIf
Until Event = 0
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

( 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 »

Fred, i added you code and it worked. I hade to keep the Delay(1) command or else the cpu usage wouldn't drop below 40%. I managed to get it to 25-30% which is normal i guess.

Tell me if this is correct:

Code: Select all

fixing
Also the objects aren't being positioned correctly. The ball should be positioned at 240,320 but, appears at 0,0 instead. The bats x position should be 300 but, appears at 0 instead. Any ideas?
Last edited by Dark Mars Software on Tue Jan 31, 2006 12:48 am, edited 1 time in total.
Straker
Enthusiast
Enthusiast
Posts: 701
Joined: Wed Apr 13, 2005 10:45 pm
Location: Idaho, USA

Post by Straker »

@Dark Mars Software

Please stop removing your previous postings just because something is solved. Please post a new reply explaining the solutions. This is to help people in the future who might be searching these forums for the same or similiar problem.

Besides, it makes my replies look stupid when you change the question. I am fully adept at making myself look foolish without help. Thank you.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Sorry, also i don't like posting my full source code as anyone can copy it and sue me claiming i stole it from them and/or modify it some and sell it without actually doing any of the "manual labor". Do you understand now?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

no :-)
( 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, if i post the full source, someone can chane the graphics, sounds and some gameplay, compile it and sell it for 5 bucks a piece without ever having to write any code what so ever. Since most of the code for a person needs for a pong clone is being posted, all the user has to do it finish it, change the graphics and sounds, compile it and sell it. Its nothing against the community.
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Listen i said i was sorry and explained myself. As i said it was for copy protection reasons. Can someone please help me out?
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Why is no one responding? Does everyone in this community hate me for doing 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 »

Of course not. It's just that a lot of the problems you're experiencing can be solved with a bit of research. There is lots of material on the forums and at Purearea.net for you to learn basic concepts on. Look for "Code Archive".
Last edited by netmaestro on Tue Feb 21, 2006 6:39 pm, edited 2 times in total.
BERESHEIT
wcardoso
User
User
Posts: 80
Joined: Fri Apr 25, 2003 5:06 pm
Location: Uruguay

Post by wcardoso »

Dark, the best you can do is what your avatar is doing... :evil:
with love from Uruguay
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

Dark Mars Software wrote:Why is no one responding? Does everyone in this community hate me for doing this?
Yes that is correct ;)
however putting that aside, you absolutely NEED to put the Initialization of the globals at the top of your source, and by that i don't mean calling a procedure that has a lot of Global statements inside. This is how i prefer to layout my source code:

Code: Select all

; First - declare constants that need defining
#My_own_constants = 1

; Second - declare structures if any is needed
Structure MyMegaStructure
  a.b
EndStructure

; Third - declare globals, arrays, linked lists
Global myGlobal.l, anotherGlobal.w

Dim AnArray.l(10, 10)

NewList My_LL.l()

; Next - declare procedures etc
Dark Mars Software
User
User
Posts: 68
Joined: Sat Jun 19, 2004 3:34 am
Location: USA
Contact:

Post by Dark Mars Software »

Pupil wrote:
Dark Mars Software wrote:Why is no one responding? Does everyone in this community hate me for doing this?
Yes that is correct ;)
however putting that aside, you absolutely NEED to put the Initialization of the globals at the top of your source, and by that i don't mean calling a procedure that has a lot of Global statements inside. This is how i prefer to layout my source code:

Code: Select all

; First - declare constants that need defining
#My_own_constants = 1

; Second - declare structures if any is needed
Structure MyMegaStructure
  a.b
EndStructure

; Third - declare globals, arrays, linked lists
Global myGlobal.l, anotherGlobal.w

Dim AnArray.l(10, 10)

NewList My_LL.l()

; Next - declare procedures etc
Thats did the trick. Thanks
Post Reply