Grid movement

This forum is currently in read-only mode.
  • 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.

    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.

  • A quick hack of your cap:

    http://dl.dropbox.com/u/2306601/gridhack.cap

    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.

  • Cool ! Thanks for the help dude, ill put you in the credits when I finish the game

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)