Page 1 of 1

KeyPress doubt

Posted: Thu Jul 19, 2012 1:51 am
by jonaspm
Hello Ville and all ZGE community!


I have a question, since im too noob for ZGE... lol


i made this:
Image

but i don´t know how to use KeyPress to rotate a bit the spacecraft to the left and right (Z?)

can you please help me? :)

Posted: Thu Jul 19, 2012 7:15 am
by jonaspm
Ville, i recommend you to open a category on the forum with the name of Newcomers


So they can ask all their noobie stuff

Posted: Thu Jul 19, 2012 7:49 am
by Kjell
Hi jonaspm,

Attached is a example of the easiest way to do this.

What kind of game are you trying to make?

K

Posted: Thu Jul 19, 2012 8:48 am
by Rado1
Hi jonaspm,

just a small tip how to achieve more natural behavior. In the example from Kjell change the following expressions in the OnUpdate section of Model:

Code: Select all

CurrentModel.RotationVelocity.Z = 0; ---> CurrentModel.RotationVelocity.Z *= 0.9;

CurrentModel.RotationVelocity.Z += 1; ---> CurrentModel.RotationVelocity.Z = 1;

CurrentModel.RotationVelocity.Z -= 1; ---> CurrentModel.RotationVelocity.Z = -1;

Posted: Thu Jul 19, 2012 8:59 am
by Kjell
@Rado1

You probably don't want to mix framerate dependent ( *= 0.9 ) and independent ( Velocity ) techniques though. Since I'm using SyncedWithMonitor the deceleration will be slower on monitors with lower refresh-rate / devices with lower performance, while the effective rotation velocity will the constant regardless of framerate.

Also, by changing "-=" and "+=" to "=" the rotation won't stop when you're pressing both left and right at the same time ( which I personally find desirable ).

K

Posted: Thu Jul 19, 2012 10:24 am
by Rado1
Kjell - yes, you are right. This was just a simplified "didactic" example of how to achieve such an effect easily. In reality, I would use FPS-independent solution, similar to the attached one. (Optionally, I would maybe access rotation directly, not by velocity.)

Posted: Thu Jul 19, 2012 10:13 pm
by jonaspm
im working on a 3D space shooter, however im more than newbie in ZGameEditor, so im having lot of questions and doubts e.e

i changed from programming the entire game in BASIC to ZGE... i think is faster this way :)

Posted: Fri Jul 20, 2012 6:54 pm
by jonaspm
hey, i have another question, sorry if i have a lot :$

¿How can i change the cursor icon?

i would like to use it as a sight

Posted: Fri Jul 20, 2012 8:04 pm
by Kjell
Hi jonaspm,
jonaspm wrote:How can i change the cursor icon?
Depends a little on how you want to handle this ( technically ). A common way is to hide the Windows cursor and show a sprite instead* Attached is a example on how to do this ( albeit a little awkward, the Font component is actually the easiest way to pull this off ).

*The windows cursor will only be hidden in a standalone executable, not in the Editor.

K

Posted: Fri Jul 20, 2012 8:38 pm
by jonaspm
thanks Kjell, i´ll test it :D

Posted: Sat Jul 21, 2012 12:56 am
by jonaspm
ok, so i tested it, and works perfectly, however i have a problem, the image shows with black background, and it shouldn´t since the background is trasparent (.png alpha channel)

Posted: Sat Jul 21, 2012 8:11 am
by Kjell
Hi jonaspm,
jonaspm wrote:the image shows with black background, and it shouldn´t since the background is trasparent
Simply change the Blend property of your cursor Material into "Alpha/OneMinusSourceAlpha" :)

K

Posted: Sat Jul 21, 2012 8:20 am
by jonaspm
OMG! thanks!!! I should have tried that :)