moveing a gui element (my setup should work!?)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

moveing a gui element (my setup should work!?)

Post by 3DModelerMan »

Hi I have a setup that should scroll my splash screen to the right, but it does'nt, here's my code that should move the splash screen

Code: Select all

while ( trans_to_menu == true )
    {
     background->move( position2d<s32>(+10,0) );
    }
could someone tell me what I'm doing wrong?.
Thanks. :D
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
nmn
Posts: 23
Joined: Tue Sep 02, 2008 7:35 pm

Re: moveing a gui element (my setup should work!?)

Post by nmn »

3DModelerMan wrote:

Code: Select all

     background->move( position2d<s32>(+10,0) );
It's not an Irrlicht related problem. Let me explain.

When C++ gets up to +10, it calculates 0+10. (I believe.) Positive 10, in other words.(So + has no effect.) It doesn't add to what you already have, as the Irrlicht documentation clearly states that parameter is "absoluteMovement" in this case, which though can mean multiple things, also means that there's no way it's relative to your current position.

To add to what you currently have is relatively easy though.

Code: Select all

position2d<s32> bgpos = background->getAbsolutePosition().UpperLeftCorner;
background->move( position2d<s32>(bgpos.X+10,bgpos.Y) );
I haven't tested it, so it's likely to have a problem of SOME sort, but that should make things move.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

The problem looks rather like an endless loop to me.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
nmn
Posts: 23
Joined: Tue Sep 02, 2008 7:35 pm

Post by nmn »

CuteAlien wrote:The problem looks rather like an endless loop to me.
Oh, that's probably also a problem :P Didn't even notice.
Use an if instead if your in a loop, or just make an entire Irrlicht loop there.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

yeah

Post by 3DModelerMan »

Well the endless loop is there so that it scrolls out the side of the screen, and later I set my variable to false, so technically it's not an endless loop.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

What do you mean later you set it to false?

int pos = 0;
bool test = true;

while(test)
{
pos++;
}

test = false;

This loop will process forever. You will have to add an update function or test within the loop when to set test to false to break out of it.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

If you've posted psuedocode, then you're just wasting your own time.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Re: moveing a gui element (my setup should work!?)

Post by Ion Dune »

nmn wrote:means that there's no way it's relative to your current position.
Negative!

Code: Select all

00451         virtual void move(core::position2d<s32> absoluteMovement)
00452         {
00453                 setRelativePosition(DesiredRect + absoluteMovement);
00454         }
You're mixing up Position and Movement.
CuteAlien wrote:The problem looks rather like an endless loop to me.
This is more likely.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Re: moveing a gui element (my setup should work!?)

Post by B@z »

3DModelerMan wrote:Hi I have a setup that should scroll my splash screen to the right, but it does'nt, here's my code that should move the splash screen

Code: Select all

while ( trans_to_menu == true )
    {
     background->move( position2d<s32>(+10,0) );
    }
could someone tell me what I'm doing wrong?.
Thanks. :D

please forget that while loops...
its an endless loop, but even if it isn't, it won't work either.

you know, it isn't multitask rendering.
so, you have to call the render function (smgr->drawAll(), guienv->drawAll() and so on)
but if you make while loops the render WON'T RUN!!!
for example you wanna move something from left to right

Code: Select all

x = 0;
while (x < 640)
{
x++;
}
.....
render()
what will you get?
the thing suddenly goes to right. same as x = 640, but more slow...
so, forget the while, when you wanna move something.
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: moveing a gui element (my setup should work!?)

Post by randomMesh »

I told you in your other thread to get used to loops before trying to code anything in Irrlicht. This is essential!
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

umm

Post by 3DModelerMan »

When I put a while loop inside my main loop nothing will work, but if I put it above everything works fine.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

...

Exactly?

You should have one while loop:

Code: Select all

while (device->run())
{
if (something) dosomething();
if (somethingelse) dosomethingelse();

if ( background->getAbsolutePosition().LowerRightCorner.X < 1000 )
background->move(position2di<s32>(10,0));

driver->beginScene(...)
smgr->drawAll();
driver->endScene();
}
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

okay

Post by 3DModelerMan »

Well my menu scrolling problem is solved. But if I was going to have a statement that requires a while loop to, like, move my character, such as this psuedocode

Code: Select all

 while arrow key is down, move the character
would I put it as an "if" inside my main game loop, or as while loop somewhere else?.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
stevend
Posts: 114
Joined: Sat Mar 01, 2008 7:18 pm

Post by stevend »

your description is pretty obscure

input from keyboard, mouse, GUI buttons, etc, should all be done in the event receiver

now if you had a property that was decided in a while loop then it could work, for example,

Code: Select all

while (device->run())
or if you reaaally wanted to , when the user presses a key, set a flag accessable by your entrypoint, like this:

Code: Select all

while (device->run()) 
{

if (MYFLAGFORLEFTKEYISDOWN)
     mycharacter->moveleft();

draw stuff

}
but why would you want to do this?
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

nope

Post by 3DModelerMan »

No, I mean where should I put another while loop when it's necessary.
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Post Reply