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.
Dr.Bunshin
Posts: 34 Joined: Sat Mar 31, 2007 8:38 pm
Post
by Dr.Bunshin » Sun Apr 01, 2007 2:18 am
Hey all
I really dont mean to flood with useless noob threads, but could someone tell me where too look to understand how this works:
Code: Select all
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
You can explain it if you want. I am sorry for my ignorance.
Last edited by
Dr.Bunshin on Sun Apr 01, 2007 5:51 pm, edited 2 times in total.
Granthus
Posts: 16 Joined: Mon Jan 22, 2007 8:04 am
Location: Australia
Contact:
Post
by Granthus » Sun Apr 01, 2007 2:40 am
Dr.Bunshin wrote: Hey all
I really dont mean to flood with useless noob threads, but could someone tell me where too look to understand how this works:
Code: Select all
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
You can explain it if you want. I am sorry for my ignorance.
Basically it is saying
Code: Select all
if (event.KeyInput.Key == KEY_KEY_W)
v.Y += 2.0f;
else
v.Y += -2.0f;
Personally I would have used some parentheses (bracket things
) to break it up and make it easier to understand - but it is making use of the 'shorthand' if statement format,
(logic test) ? TRUE : FALSE
Hope that helps
Granthus
khamill
Posts: 17 Joined: Thu Mar 08, 2007 3:50 pm
Location: Nova Scotia, Canada
Post
by khamill » Sun Apr 01, 2007 2:45 am
v.Y (probably a y-axis cordinate) is getting incremented by the result of:
event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
This says, if InputKey equals W, increment by 2.0, if not increment by
-2.0. The f on the 2.0 just stands for a floating point number.
Hope this helps.
Kevin
Dr.Bunshin
Posts: 34 Joined: Sat Mar 31, 2007 8:38 pm
Post
by Dr.Bunshin » Sun Apr 01, 2007 3:51 am
Hey guys!
Thank you so much! Thats about what I was thinking but you made it very clear. That is quite short short-hand if you ask me.
Thank you again.