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 / arrays

Author
Message
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 9th Dec 2011 14:36


hello guys i was wondering why this doesnt work. maybe im not correct with it but some other languages i used before was fine. so i thought it would be the same with vc 2008 cpp.

any idea with this?

-Excellence deals with weak people-
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 9th Dec 2011 16:03


note that shooter does not have a comma after it. This will have the same effect that I think you are tryin.g to achieve but the first offset will be position 0 (zero) and not position 2 (two).

One word of advice: consider using std::string instead of char* you can look it up in the compiler's help des.

JTK
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 9th Dec 2011 16:10
string.h would let me use string as a variable.. but do i have to write namespace std?

thanks alot with the heads up.

-Excellence deals with weak people-
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 9th Dec 2011 17:10
look at attachment.

it has an arrow pointing my
dbLoadImage(image_name[image], image);

heres my code.


-Excellence deals with weak people-

Attachments

Login to view attachments
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 9th Dec 2011 18:18 Edited at: 9th Dec 2011 18:27
You can avoid the std:: by adding the line

using namespace std;

Right after all of the #include statements.


Secondly, the exception:

You load the image as Id 2, but stretch sprite calls for image-2. Before that but after loading the image, you increase the id to 3. So, 3-2=1 which by your code above does not exist.... Thus, your exception...

Hope this helps you figure it out...

JTK

Edit: what was I thinking? Isn't the first parameter to dbStretchSprite the id of the sprite to stretch? In any case, you still did not create a sprite with an id of 1. In fact you didn't even create any sprites at all.
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 10th Dec 2011 05:54 Edited at: 10th Dec 2011 06:04
my purpose of image-2 is to increase the width of the sprite_id 1 every load completes.


the stretch sprite call id 1 and adjusts its width by (image-2)*100/6.

i dont really get it why theres an exception.

-Excellence deals with weak people-
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 10th Dec 2011 07:23
So image id 1 does exist? You don't show its creation anywhere.

Are you sure that you are not calling load_mainmenu() to many times? Once you call it to load the shooter.png file, image will equal 8 which is an invalid array position.

We may need to see more code to help with this...

JTK
chan
13
Years of Service
User Offline
Joined: 14th Nov 2011
Location:
Posted: 10th Dec 2011 14:39
it worked like a dream



now i know why it has an exception. its because im calling load_mainmenu too many times. thanks alot..

i will add you to my credits.

-Excellence deals with weak people-

Login to post a reply

Server time is: 2024-11-19 06:34:22
Your offset time is: 2024-11-19 06:34:22