Hey guys!

i just started using SDL engine to make a 2d game . This is the code ive got so far, you can view it online on googledocs via this link:

CODE

i have made bold the code that causes the problem.

when i do apply_surface(0, 0, stick, screen, &runStick[frame]); there is no problem and the animation is displayed at the x = 0 and y = 0.

but when i swap it with the class variables 'Stick::x' and 'Stick::y' or just 'x' or 'y' which are also initialized to 0, the animation just does not appear..

i can't seem to find the solution and my debugger wont function properly.

any help will be greatly appreciated.
Thanks :D

The problem is in the constructor. You are declaring three new integers (x, y and frame). After the constructor is done those three do not exist and stick::x, stick::y, stick::frame are not modified at all. So what you need to do is remove int from in front of

x = 0;
y = 0;
frame = 0;

so that it modifies the stick's variables.

If you cant get your debugger working then just enable the console window and use cout. Or if you are using visual studio and for whatever reason the console window doesn't wanna show up, you can use fstream and write to a file. Because I ran your code with outputs and saw that x and y were huge values which normally means that they are uninitialized.

OMG thanks so much.. wow i thought that would be atleast calling a compiler error .. cost me many hours :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.