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 / Newbie help

Author
Message
tonycrew
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location:
Posted: 3rd Mar 2010 12:21
Ok i did C++ over 10 years ago but i just started getting into this, i'm trying to write a cafe type game, nothing spectacular but it will help me learn as i go along.



As you can see from my code i'm doing alot of clearing the screen and reloading the bmp so that i can update, it works fine but i know i am doing it wrong, anyway i think i should be using functions, i'll post what i think i should be doing then if anyone can point me in the right direction i would be very greatful, BTW i ain't got buttons or graphics yet it's all text just while i learn the code.

Should i have Functions for each item in my cafe, Pizza Function and Chips function Tea function ETC. As each item has a cooking time and money value as well as EXP value, Then can i call the EXP function or update the EXP function when needed, are these called Global functions...?

Thanks for any help

FPS Creator Updated 116,Vista 32Bit UpTo Date, nVidea 8500 1Gig Graphics Card, 4 Gig DDR2 Ram, Intel Duel Core 3GHZ CPU
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Mar 2010 12:42
A couple of things...

The # symbol does NOT make a variable a 'number'. It makes a number variable a float (real) number. Leaving off the # makes them integer numbers.

So, don't use it unless you really do need to use floats, and when you do, use float numbers with them. (Using integers over floats makes your programs run slightly faster too).

For example every one of your numeric variables are floats, but you only ever store integers in them:

Level#=1
NextExp#=500


...should be:

Level=1
NextExp=500


or:

Level#=1.0
NextExp#=500.0


..depending on whether you actually need them to be integers or not.

Second, don't use Load Bitmap. It's not used in that way. (Look up the commands Create Bitmap and Set Current Bitmap for more info).

Instead, use Load Image outside the main loop and use Paste Image where you are currently using Load Bitmap.

Third, you only need to set the text to bold once - not before every use of the Text function. Oops - sorry scrub that - I just spotted that you have used Set Text To Normal for other printing... but that introduces another problem:

None of the Set Text commands affect the Print command - only Text and Center Text, so all your Set Text commands are redundant.

Putting Set Text To Bold once outside of the loop is all you need for the same results. (Unless DBP has changed from DBC).

So, always put as much as you can outside the loop - especially stuff which only needs to be done only once.

TDK

tonycrew
14
Years of Service
User Offline
Joined: 8th Jan 2010
Location:
Posted: 3rd Mar 2010 13:09
Thankyou very much for your time and help, i remember now from C++ Floats can have Decimal places, dam it's so long ago...

After searching around this forum i found that i am probably best to use Subroutines for the items in my cafe game as i can call them easier also Functions don't store Variables i think as it has to be passed to it. Again thankyou, off to do some more reading and search, dam i love this place.

FPS Creator Updated 116,Vista 32Bit UpTo Date, nVidea 8500 1Gig Graphics Card, 4 Gig DDR2 Ram, Intel Duel Core 3GHZ CPU
Travis Gatlin
15
Years of Service
User Offline
Joined: 14th May 2009
Location: Oxford, Alabama
Posted: 7th May 2010 04:34
i thought there was a sticky thread that specifically said dont name threads something like "newbie help"

Google.com. Nuff Said

Login to post a reply

Server time is: 2024-11-23 17:02:42
Your offset time is: 2024-11-23 17:02:42