More Noob Questions

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.
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

Alright, I went looking for wchar_t and came up with stringw.

One problem.

Right now this is what part of my code looks like

Code: Select all

health->setText(varhealth.c_str())
This is awesome, but I want it to print out "Health: (varhealth)" not just the number.

How would I do this?
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Irme
Posts: 55
Joined: Sat Jul 16, 2005 8:24 am

Post by Irme »

My C++ skill is limited, but i believe you do this:

Code: Select all

health->setText("Health: " + varhealth.c_str())
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

O.K.

Sorry Irme but that didn't work...

But I did find how to do it by looking at the fps counter at the end of each tutorial.

Code: Select all

int inthealth;

inthealth=100;

stringw varhealth = L"Health:";
varhealth += inthealth;
health->setText(varhealth.c_str());
Output is "Health:100"

YAY! :D

Thank everyone for your help. :)

I'll probably have more problems later though... :P
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

I have another question.

How would I make my character jump? :P
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Reversing the gravity on your collision would be one way to go about it.
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

That would make it so that when you jump you start slow and end fast?
Usualy when you jump you start fast and end slow. :P

I also don't understand the event handler...
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

LemonMan wrote:That would make it so that when you jump you start slow and end fast?
Usualy when you jump you start fast and end slow. :P

I also don't understand the event handler...
I don't think Irr's gravity is fancy enough to start you slow. I think you just move a set number of units based on time.

What do you not understand about it?
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

Everything...

I mean, something to do with the fact that is a function that comes before the main one and it is referencing nodes and stuff that have not yet been made. Did that make any sense?
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

LemonMan wrote:Everything...

I mean, something to do with the fact that is a function that comes before the main one and it is referencing nodes and stuff that have not yet been made. Did that make any sense?
Main is always ran first. Functions can't call themselves. When you write a function before main the program still starts on main. Irrlicht calls the event receiver itself during the device->run() procedure.
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

Ohhhhhhhh...
That makes more sense.

Could you write me a quick example or the event receiver?
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

LemonMan wrote:Ohhhhhhhh...
That makes more sense.

Could you write me a quick example or the event receiver?
Well... the movement tutorial has a nice simple example of one and how it works...

The GUI tutorial has another nice example of it...
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

O.K.

Thank you. :)
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

Hi again,

I have gotten the event handler thing but I don't know how to do mouse button handling.

This is the code i'm using,

Code: Select all

IAnimatedMeshSceneNode* uzi = 0;

class MyEventReceiver : public IEventReceiver
{
      public:
             virtual bool OnEvent(SEvent event)
             {
                     if (uzi != 0 && event.EventType == EET_KEY_INPUT_EVENT&&event.KeyInput.PressedDown)
                     {
                              switch(event.KeyInput.Key)
                              {
                                                        case KEY_SPACE:
                                                             {
                                                                       //shoot
                                                             }
                                                             return true;
                              }
                     } return false;
             }
};
help... :P
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
SwitchCase
Posts: 170
Joined: Sun Jul 01, 2007 11:41 pm
Location: Manchester, UK

Post by SwitchCase »

Code: Select all

IAnimatedMeshSceneNode* uzi = 0; 

class MyEventReceiver : public IEventReceiver 
{ 
      public: 
             virtual bool OnEvent(SEvent event) 

             { 
                     if (uzi != 0 && event.EventType == EET_KEY_INPUT_EVENT&&event.KeyInput.PressedDown) 
                     { 
                              switch(event.KeyInput.Key) 
                              { 
                                        case KEY_SPACE: 
                                        { 
                                                  //shoot 
                                        } 
                                        return true; 
                              } 
                     } return false; 

// Add code here!!!!!!!!!

             } 
};
This code goes there...

Code: Select all

		     if (event.EventType == EET_MOUSE_INPUT_EVENT)
		     {
			     // switch
				// case
					//stuff
						// goes here
		     }
good luck.
LemonMan
Posts: 16
Joined: Sat May 26, 2007 4:49 pm
Location: Duluth, Minnesota, U.S.A.
Contact:

Post by LemonMan »

What?
GO HERE NOW! please? :)
My friends website - http://www.ecoblues.net/joomla/

My website - http://www.harborcityschool.net/~pjewell
Post Reply