KeyPress doubt

All topics about ZGameEditor goes here.

Moderator: Moderators

Post Reply
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

KeyPress doubt

Post 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? :)
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post 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
User avatar
Kjell
Posts: 1897
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Rotate.zgeproj
(1.14 KiB) Downloaded 441 times
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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;
User avatar
Kjell
Posts: 1897
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
User avatar
Rado1
Posts: 775
Joined: Wed May 05, 2010 12:16 pm

Post 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.)
Attachments
Rotate.zgeproj
(1.38 KiB) Downloaded 451 times
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post 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 :)
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post 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
User avatar
Kjell
Posts: 1897
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Cursor.zgeproj
(2.16 KiB) Downloaded 440 times
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post by jonaspm »

thanks Kjell, i´ll test it :D
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post 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)
User avatar
Kjell
Posts: 1897
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
User avatar
jonaspm
Posts: 89
Joined: Fri Jul 06, 2012 3:51 pm
Contact:

Post by jonaspm »

OMG! thanks!!! I should have tried that :)
Post Reply