Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problem with my first project.

Author
Message
akeith83
15
Years of Service
User Offline
Joined: 3rd May 2011
Location: Ohio, USA
Posted: 4th May 2011 07:19
I'm going through the book "DarkBASIC Pro Game Programming, 2nd Ed. and I'm having a problem with my first project. Its a basic pong type game but the ball only moves up and down, but not side to side. I doublechecked that I copied everything correctly. Could anyone take a look at my code and help me find what I did wrong?

Daniel wright 2311
User Banned
Posted: 4th May 2011 08:42 Edited at: 4th May 2011 08:47
When you inc your positions you first need to declear them, you did not do this, but here is a real good example pong game already set up from me dong a search.You can learn just from looking at the code. Also you should do it with sprites so all you need to do is move the sprite and not incress any positions.just make a sprite out of the ball you drew like in this demo project.



my signature keeps being erased by a mod So this is my new signature.
Jimmy
22
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 4th May 2011 11:00
@akeith83: That's strange, the code works fine on my computer. Do you have the latest DBP upgrade (7.6 or 7.7 RC) installed?


May 10th / Geek Culture / Jerico2day-OBese87 / VOTE
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 4th May 2011 11:23 Edited at: 4th May 2011 11:24
Quote: "That's strange, the code works fine on my computer. "

It works fine on mine as well but I do remember this problem when I was going through this book. What I think is happening is that since the ball is white and the point command checks for a pixel greater than black, it sees the ball's pixels as white and changes the xspeed. The easiest solution is as Jimmy suggest, upgrad to the latest version of dbpro found here.

Here is the code that I used to get around it back when I had this problem.



A clever person solves a problem, a wise person avoids it - Albert Einstein
akeith83
15
Years of Service
User Offline
Joined: 3rd May 2011
Location: Ohio, USA
Posted: 4th May 2011 23:10
I do have the latest update. I've tried it in win7 and winxp and my code still does the same thing.

And thank you for the code Hodgey that one worked great for me. I just can't understand why my code working for you guys and not me.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th May 2011 00:19
It's due to a difference in video cards.

When the video mode is set to a non-alpha mode, some cards pass back a colour with an alpha value of 0 and some pass it back with an alpha value of 255 - that means that if your card does pass back an alpha value of 255, it is interpreted as a negative value, as the high-bit is set - if you know how binary 2's complement numbers are represented, you'll know how that works.

What Hodgey's fix does is to extract the green component from the colour and use that instead, so that the comparison no longer relies on the alpha value.

akeith83
15
Years of Service
User Offline
Joined: 3rd May 2011
Location: Ohio, USA
Posted: 5th May 2011 01:46
Thanks IanM. That makes it a little more clear for me. The card I'm using is the saphire radeon 5570 1gb ddr3.
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 5th May 2011 09:39
@ akeith83: glad my code works for you

@ IanM: you know more about my fix than I do . One of these days you are going to have to tell me your secret on how you know so much, is it because you have a moon base?

A clever person solves a problem, a wise person avoids it - Albert Einstein

Login to post a reply

Server time is: 2026-07-10 21:40:56
Your offset time is: 2026-07-10 21:40:56