How to declare actor's position in variables?

Talk about making games.

How to declare actor's position in variables?

Postby bat78 » Tue Mar 26, 2013 4:48 pm

Hello, who have original way to declare actor's x&y position in variables :)
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: How to declare actor's position in variables?

Postby lcl » Tue Mar 26, 2013 4:53 pm

Every actor has a set of variables, that are specific to only that certain actor's certain clone.
These variables are called actor variables, and they include things like: x, y, animpos, animindex, angle, directional_velocity, xvelocity, yvelocity, ...

So, you can set an actor's x and y like this:
Code: Select all
myActor.x = 150;
myActor.y = 300;

And you can also read from the variables, for instance, let's make the actor actor2 move to myActor's x position:
Code: Select all
actor2.x = myActor.x;

Explanations of actor variables and other variables and functions can be found here: http://game-editor.com/docs/script_reference.htm
Hope this helps! :)
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: How to declare actor's position in variables?

Postby bat78 » Tue Mar 26, 2013 4:59 pm

Ive read the whole reference and ik how to set an actor in x and y position but what i meant is how to make something like that:
Code: Select all
Actor --> Draw Actor --> Script Editor:
int i = actor.x
int a = actor.y
variable = screen_to_actor(&i, &a)


I want each time when the actor move to x the var have to change the value to the x amount that the actor moved
So i can load/save the actor's position :)
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: How to declare actor's position in variables?

Postby skydereign » Wed Mar 27, 2013 8:31 am

bat78 wrote:Ive read the whole reference and ik how to set an actor in x and y position but what i meant is how to make something like that:

Then you are over thinking things. All you want to do is store an actor's xy position in a variable. You provided code to do that. Now if you wanted to use a variable that can be used in saveVars it is slightly more involved, especially if you want to save positions of clones. The way to do that is to create int arrays, using cloneindex to locate the position in the array.
Code: Select all
x_array[cloneindex] = x;
y_array[cloneindex] = y;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: How to declare actor's position in variables?

Postby bat78 » Wed Mar 27, 2013 11:16 am

You understood what i want, but i did it on another way. Without arrays :o
When an actor is in collation with an another actor the hpmeter.x move:
Code: Select all
hpos=hpos-...


the hpmeter in draw actor have:
Code: Select all
mage_health.x=hpos;
saveVars(...)


And hpos is an normal variable stored in the group that i made to save.
That sounds simple enough and no need to use strings. I mean arrays.
I make a simple test. I make one text actor 0. And i make it with draw actor:
Code: Select all
textactor.textNumber=hpos

So i aways can see how is the hpos when the game start and is it changes and how :D I aways find the way to do everything i want, with different time of course. I submit
in the forums with the idea someone will help me before i get it. Just saying that to tell all that i am not that stupid, because i took a look and i feel like ppl think of me like a stupid xD Thanks for the responsability and sorry for my terrible language :)

I also made that. Counters that aways count the actor's x and y position that you do by moving with arrow keys. Also automatic save them from any change. And loads them automatic:
locationer.exe
(1.38 MiB) Downloaded 140 times
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest