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.

Newcomers DBPro Corner / Mouse Click and the IF statement - Beginner!

Author
Message
Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 16th Dec 2008 11:07
Hi,
A few years a go i bought DarkBASIC pro and the book "Beginners's Guide to DarkBASIC Game programming", although i never opened it 'till now.

Im up to chapter 6, about IF statements. This is my fist exposure to the IF statement as i am an absolute programming beginner.

The first program in the chapter is simply supposed to return printed text when either the right or left mouse button has been clicked. The source code, as it appears in the book is:



This program simply flashes a black screen, i assume because the IF statement is not working. I looked around in the DarkBASIC pro help file and found a list of commands, and one of them was MouseClick, so i tried replacing the word MouseButton with MouseClick, but still no joy.

I think the book is mainly written for DarkBASIC and this may be one of the differences in DarkBASIC pro, any help would be much appreciated.

Regards,
Siddy.
Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 16th Dec 2008 12:53
Ok, well while i was waiting for this thread to be cleared by the mods, i tried everything under the sun to get it working, and i did!

Here is what ive come up with:


From what i can tell, DarkBasic used "MouseButton = 1" and DarkBasic Pro uses "MouseClick() = 1" (for left click).
I added the Do...Loop so the screen doesnt close and you can see it works!

!!!BUT!!!

I have a new problem, the next example doesnt work for me either, i have looked and i cant find any obvious things i can change.


The problem is, the program should bounce the circle off the screen walls, but it doesnt. Any help!!!???
BlobVanDam
16
Years of Service
User Offline
Joined: 26th Jul 2008
Location: one of Cybertrons moons
Posted: 16th Dec 2008 13:22
That bouncing ball code works perfectly for me in Darkbasic Pro 7.1
Try upgrading to the latest version. Can't help beyond that since I don't know what it's doing wrong.

And as far as I recall, the code for the mouseclick is the same in DB Classic. Seems like MouseButton is a variable it should be updating elsewhere in the code, I don't know, but nice work on figuring it out for yourself. Solving problems is a key part of being a good programmer, so you're off to a good start
Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 16th Dec 2008 14:58
Thanks for the reply.

The Circle Game (the 2nd source code) is supposed bounce around the screen, however after a few seconds it gets stuck. Thats the problem i have.

Also i have another problem, this program:


Is supposed to count down from 10 to 1, but it starts from 8.

I tried it in FreeBasic (had to alter the code a little:


In FreeBasic it correctly counts down from 10, but in DarkBasic it skips the first 2 numbers and starts at 8. Any ideas?
Guyra
19
Years of Service
User Offline
Joined: 10th Nov 2005
Location: Norway
Posted: 16th Dec 2008 20:14 Edited at: 16th Dec 2008 20:17
Your code works perfectly:


I don't have any idea what the problem you experience is, but I would bet it's local to your computer. Tried compiling it and running it on someone else's computer?

Also, try upgrading DBPro to the latest version, and make sure you have the latest DirectX installed.

baconboy2
17
Years of Service
User Offline
Joined: 30th Jul 2007
Location: Liverpool, UK
Posted: 16th Dec 2008 20:22
Yeah, all the code you've supplied works perfectly on my computer, so I agree with Guyra and Blob, its probably your machine.

Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 17th Dec 2008 01:38
Thanks for the help.

I tried it on two other computers, new computers with good graphics cards, win XP and Vista, Direct X 9.0c, still has the same problem.
So it must be the compiler right? I dont understand why it wont work though i bought it brand new a few years ago, and im not trying to use a new command that wasnt in the old vr. I wish i opened it when i bought it, when it still had a warranty!

When you guys say to "upgrade" darkbasic, does that mean purchase the new vr or can i upgrade my old vr for free?
Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 17th Dec 2008 02:24
Could come one try running the EXE i have compiled.

It should run exactly as in Guyra's post above.
If it starts from 8 instead of 10 then it has the issue im talking about.

If someone can run the EXE i made, then it will tell me if it is really my system (all 3 computers in my house) or the compiler.

Attachments

Login to view attachments
Siddy
15
Years of Service
User Offline
Joined: 16th Dec 2008
Location:
Posted: 17th Dec 2008 02:48
I downloaded the "DarkBasic Pro Demo", which is obviously the new vr. and it all works now. Im very confused as to WHY the old vr doesnt work, as im using a book from the same year?

Thanks again guys!

Login to post a reply

Server time is: 2024-11-24 16:25:19
Your offset time is: 2024-11-24 16:25:19