Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,449 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Adress to variable #185689
02/25/08 18:32
02/25/08 18:32
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Im looking for a way to store the same value in two different pointers. Notice THE SAME. Not copies. For example, I wanna have a pointer to what key_a has stored in it. I.e. id like to be able to do something like this:

Code:

typedef struct
{
var jump;
[...]
} KEYMAPPING;

[...]

KEYMAPPING* my_key_mapping =
{
jump = &key_w;
}



Is it possible to achieve this somehow? Lite-c doesnt seem to support C/C++'s adress-of operator &.

Last edited by Kenchu; 02/25/08 18:43.
Re: Adress to variable [Re: Kenchu] #185690
02/25/08 18:45
02/25/08 18:45
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Lite-C does support the address of operator. What problem are you having with it?

You might also want to look up key_set () in the manual. It's made for keyboard remapping.

Re: Adress to variable [Re: Excessus] #185691
02/25/08 19:12
02/25/08 19:12
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
After a closer look, yeah it seems like lite-c supports it. However it didnt solve my problem. Now when I declare a var* that points to &key_w, the program crashes. For example this will crash the program:

var* lol = &key_w; (if global, and if initialized within function it still crashes.)

key_set does not suffice, since im checking keys every frame.
Maybe the key_w isnt a var? It says flag in manual, but there is no type FLAG so i dunno what to do.

Last edited by Kenchu; 02/25/08 19:17.
Re: Adress to variable [Re: Kenchu] #185692
02/25/08 19:18
02/25/08 19:18
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Maybe key_w is a bool? I don't know. Or maybe it's not possible to get the address of engine variables..

You should indeed set it up in a function.

I don't understand why you can't use key_set..

void jumpEvent(){key_mapping.jump = TRUE;}
then use key_set to fire jumpEvent when a certain key is pressed.

Re: Adress to variable [Re: Excessus] #185693
02/25/08 19:39
02/25/08 19:39
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Jump is a bad example, even though the way I wanna use it cannot be done with simply a function, its too hard for me to explain in english (and Ive already completed it anyway, what Im doing now is just trying to seperate the mapping so it can be changed easily).

But otherwise movement cannot be done with simply a function for each key. Only if youd have an key_up/mouse_up event, and afaik there is no such thing in lite-c.

So for example if I want my avatar to move left as long as i keep my A key pressed, that cannot be done with key_set, right? Then Id have to use if(key_a), and as I said, Id rather use something like my_key_mapping.key_left (key_jump, key_run etc) or something ... Also, im using gamepad joysticks for movement, so its pretty much not possible to do that anyway (I guess?)

Last edited by Kenchu; 02/25/08 20:19.
Re: Adress to variable [Re: Kenchu] #185694
02/25/08 20:20
02/25/08 20:20
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi Kenchu!

I use the c_move :

Code:
c_move (my,vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0),
nullvector, IGNORE_MAPS | ACTIVATE_TRIGGER | IGNORE_CONTENT | USE_BOX | GLIDE | IGNORE_PASSABLE); //



Will this help.

Ottawa

Re: Adress to variable [Re: Ottawa] #185695
02/25/08 20:56
02/25/08 20:56
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Hehe this wasnt really what I was asking about. But thx anyways.

I wanna get rid of things such as key_a, key_b. I dont wanna hard-code keys to do specific things. Id rather have a variable, for example key_jump, that can change, but the code remains the same.

Re: Adress to variable [Re: Kenchu] #185696
02/25/08 21:03
02/25/08 21:03
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Just use key_pressed(x) and a variable with the scancode. That's easier

Re: Adress to variable [Re: Lukas] #185697
02/25/08 21:12
02/25/08 21:12
Joined: Jan 2008
Posts: 49
Sweden
K
Kenchu Offline OP
Newbie
Kenchu  Offline OP
Newbie
K

Joined: Jan 2008
Posts: 49
Sweden
Ah excellent. That will do.
And now my mapping will work aswell.

Oh and thx.

Last edited by Kenchu; 02/25/08 22:00.

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