Grid movement

For questions about using Classic.

Post » Sat Nov 13, 2010 5:30 pm

I am trying to make a grid based game (like Advance Wars).I tried to do movement like this:
when the grid is clicked - move the object horisontal by :absolute value of (grid.X) - object.X pixels
and vertical by: absolute value of (grid.Y) - object.Y pixels

Since the program wont do both things one after another in one event (I dont know why by the way) I tried deleting the "move vertical" action.Then I added a global variable "timer" that gets -1 every second when grid is clicked,and set that timer to
(absolute value of (grid.X) - object.X pixels) / 64. when grid is clicked.

Finnaly when the timer reaches 0 move the object vertical by : absolute value of (grid.Y) - object.Y pixels.But the timer is messed up and doesnt work as it should.When it gets to 1 it quickly goes to zero before a second finishes and the object doesnt go vertical. :shock:
Heres the .cap file : http://www.hostmyfilez.com/j430e779alqx/Grid.cap
Ignore the bookmarked events,I dont think they cause the problem.

Any help would be greatly appreciated.
B
2
G
2
Posts: 34
Reputation: 718

Post » Sat Nov 13, 2010 6:03 pm

A quick hack of your cap:

[url:33jjw8sv]http://dl.dropbox.com/u/2306601/gridhack.cap[/url:33jjw8sv]

Just uses an Array to hold 2 variables basically. You could also use 2 PVs or Globals instead. Don't really get what you intended to do with that timer, but oh well, I'm in a hurry right now. Check it out. :wink:
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sat Nov 13, 2010 9:04 pm

Cool ! Thanks for the help dude, ill put you in the credits when I finish the game :D
B
2
G
2
Posts: 34
Reputation: 718

Post » Mon Nov 15, 2010 6:48 pm

Sorry for bothering here again (lol) guys but I have another problem with the same game:
I have three objects. The first one has a private variable "health".When the first object concludes the second one I want 1 to be substracted from first object's "health" , and then if the value "health" is greater than 0 the first object to spawn the third object.I tried this :
http://www.hostmyfilez.com/zd4zfuuar34w/Untitled.jpg
But the program only completes the first event :?
Any ideas why,and is there another way?
B
2
G
2
Posts: 34
Reputation: 718


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests