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.

Dark GDK / if (dbMouseClick() == true) // not working

Author
Message
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 28th Jun 2010 19:31
Basically I'm trying to make a little game (my first with the Dark GDK) that first displays a background and sprite (the starting screen)
and then, when the mouse is clicked, have the program execute some code. In my case its a starting screen telling the player to click to roll the dice, and when they player clicks, the random dice simulator will do its job.

here is my code:



The dice generator works great when it runs first thing, but when I want it to run after a mouse click, it doesn't work.

Any help would be great!

Thanks again

Learning C++
Proud member of www.codecall.com
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 28th Jun 2010 21:32 Edited at: 28th Jun 2010 21:43
this code will not wait the user to click the mouse, you need to be clicking it while the application is initializing, which is probably not what you want, also i dont think dbMouseClick returns the right values without LoopGDK ( ), also you need dbSprite calls inside loops, so i think the best solution which will solve all the problems is to move the first if condition (if ( dbMouseClick ( ) == true ) ) and put it inside the main loop, so it will keep updating until the user clicks escape, and meanwhile, if the user clicks the mouse, the condition will become true, also i think you need to rethink the way you are doing it, it looks pretty much wrong..how about this?: load all the images at start (before loop), and give for example, dice1 image the id of 1, dice2 the id of 2, etc, so when you attempt to call dbSprite, you dont make a condition for every possibility, rather than that you'll just use dbSprite (...., roll);
dbSprite (...., roll2);
if you loaded images and assigned them properly, this way will be much more efficient.


Sorry if most of what i wrote didnt make sense, im sitting in a noisy place and i cant focus at all

EDIT: some pseudo code might be helpful:


also a little tip might help, if you want to load, a bunch of images with the same name just a difference in a number or whatever, you can do something like


Hope it helps

TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 28th Jun 2010 22:00
Ahh! Your way of doing it seems twice as efficient as what I was doing I'm really new to C++ so I guess you could say I'm going through the "if statement phase"

That helps alot, and hopefully it gives the intended results

Thanks Again!

Learning C++
Proud member of www.codecall.com
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 29th Jun 2010 17:52
So, when I compile my program from Visual C++ Express it works fine, but when I run the debug and build applications from the folder I compiled it to All that comes up is the window with a black screen

Here is my code:



any advice?

Learning C++
Proud member of www.codecall.com
TeenCHristian
14
Years of Service
User Offline
Joined: 22nd Jun 2010
Location:
Posted: 30th Jun 2010 00:48
Sorry for triple posting, but I just wanted to say I found the answer here:

http://forum.thegamecreators.com/?m=forum_view&t=168658&b=22

Thanks anyway

Learning C++
Proud member of www.codecall.com

Login to post a reply

Server time is: 2024-11-19 20:47:34
Your offset time is: 2024-11-19 20:47:34