Page 1 of 1

2D Sprite movement question

Posted: Thu Jun 02, 2005 4:34 pm
by natol
I am using the 2D tutorial and trying to implement movement with the keyboard based off of the movement turorial

Here is my sprite code:

Code: Select all

driver->draw2DImage(sprite1, core::position2d<s32>(270,105),
            core::rect<s32>(0,4,28,36), 0,
            video::SColor(255,255,255,255), true);
in the movement tutorial you create

scene::ISceneNode* node = 0;

at the beginning and then in the even receiver you call upon node

how would I use this code with the above sprite?

or could someone give me an example.

Posted: Fri Jun 03, 2005 4:42 am
by bitplane
the simplest way to do this is something like:

Code: Select all

driver->draw2DImage(sprite1, core::position2d<s32>( spritex ,105),
            core::rect<s32>(0,4,28,36), 0,
            video::SColor(255,255,255,255), true);
then to move left...

Code: Select all

spritex -= 1;
or right...

Code: Select all

spritex += 1;
you're probably best off reading a book on game programming though, i'm guessing this would be page 1 in most books.

Posted: Fri Jun 03, 2005 12:02 pm
by Guest
I understand that to move an object you would use the

spritex.x -= 1;
s[rotex.x += 1;

my question is when I'm creating the even receiver how would I declare the variable for the sprite such as they did in the movement tutorial

Code: Select all

/*
In this tutorial, one of our goals is to move a scene node using some
keys on the keyboard. We store a pointer to the scene node we want to
move with the keys here.
The other pointer is a pointer to the Irrlicht Device, which we need
int the EventReceiver to manipulate the scene node and to get the 
active camera.
*/

scene::ISceneNode* node = 0;
IrrlichtDevice* device = 0;
Then node is used for the event receiver.

so instead of scene::ISceneNode* node = 0 what would I use for a 2D sprite?

Posted: Fri Jun 03, 2005 3:11 pm
by bitplane
hrm...
i spose you could try one of these instead then, since it inherits from ISceneNode
http://irrforge.org/index.php/Playing_2 ... h_Irrlicht

Posted: Fri Jun 03, 2005 5:07 pm
by natol
I just tried out that code and I get some errors

Code: Select all

12 C:\Data\irrlicht-0.10.0\examples\Sprite\sprite2test.cpp expected constructor, destructor, or type conversion before string constant 

12 C:\Data\irrlicht-0.10.0\examples\Sprite\sprite2test.cpp expected `,' or `;' before string constant 
this is on this line

Code: Select all

void main()

Posted: Fri Jun 03, 2005 5:48 pm
by bitplane
ooh... '#' was missing from the final #include. fixed now

Posted: Fri Jun 03, 2005 7:18 pm
by Natol_guest
thanks for the help I will try this out now

Posted: Fri Jun 03, 2005 7:44 pm
by natol
Now I get this error

Code: Select all

  [Linker error] undefined reference to `_imp___ZN3irr12createDeviceENS_5video13E_DRIVER_TYPEERKNS_4core11dimension2dIiEEjbbbPNS_14IEventReceiverEPKw' 
:(

Posted: Fri Jun 03, 2005 8:08 pm
by bitplane
yikes, i give up. try getting the 2d sprite code working on its own before adding your keyboard code.
since you didn't spot the missing # on the include line i'm guessing you're not reading it, and reading helps a lot!

Posted: Fri Jul 08, 2005 10:48 pm
by Krypt
i get that same error krypt, trying to use devcpp while doing the hello world tutorial.