Gamestudio Links
Zorro Links
Newest Posts
How to select between IB accounts by script?
by Jack_Zodiac. 06/12/26 23:17
Zorro tutorial ideas?
by pr0logic. 06/12/26 13:36
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/12/26 08:50
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
Z9 getting Error 058
by k_ivan. 06/10/26 14:38
ZorroGPT
by TipmyPip. 06/10/26 13:07
Z12 live performance
by alx. 06/09/26 20:42
Lapsa's very own thread
by Lapsa. 06/08/26 22:41
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (Quad, TipmyPip, pr0logic), 2,041 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Simple movement [SOLVED] #383263
09/18/11 10:34
09/18/11 10:34
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Hi there!
I'm currently working on a leveleditor for a Jump n' Run game.
Saving / Loading levels from text-files, deleting blocks, moving
the camera, ...
Everything works fine - but again I've got problems with the simplest part.

I want to move an entity with the W,S,A,D-keys in 4 directions (X+ / X- / Y+ / Y-).
The W-key (for example) should always move the entity away from the camera.

I'm using this at the moment:
Code:
move_vec.x = key_w - key_s;
move_vec.y = key_a - key_d;

vec_rotate(move_vec, vector( integer(camera.pan / 90 + 0.5) * 90, 0 , 0 ));



But it doesn't work correctly.


Click to reveal.. (for those who still don't know what I'm talking about)

Code:
C = camera

        A
 C >  S   W
        D

-------------------

    W
  A   D
    S

    ^
    C





POTATO-MAN saves the day! - Random
Re: Simple movement [Re: Kartoffel] #383268
09/18/11 12:29
09/18/11 12:29
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Didn't text it. Its just the way I would start to, in case that the camera looks to arbitrary directions.

vec_set(temp, camera.pan);//set an interims vector to the angel of the camera
(for key_a you don't need to change anything here, but for the other keys do something like the following here: temp.pan += 180;//for key_s - temp.pan += 90;// for key_d or a)
vec_for_angle(temp, temp);//change the angle to a vector
vec_scale(temp, key_w);//multiply the vector with the key value (1 or 0)
vec_add(object.x, temp);//add the vector to the object's position

Re: Simple movement [Re: Pappenheimer] #383269
09/18/11 12:34
09/18/11 12:34
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Thanks for the reply!

I'll try it.


POTATO-MAN saves the day! - Random

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1