Jump to content


Photo

Grid Snapping Problem


  • Please log in to reply
2 replies to this topic

#1 bobbyjones44

bobbyjones44

    GMC Member

  • GMC Member
  • 16 posts
  • Version:GM:Studio

Posted 08 May 2007 - 07:38 PM

I'm trying to make a 16X16 grid based movement system but my character will not snap to the 16X16 grid. It skips 2 "spaces" in my grid like its snapping to a larger size grid.

Its kinda sloppily put together because I "ripped" it out of my game.

download
  • 0

#2 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5379 posts
  • Version:GM:Studio

Posted 08 May 2007 - 09:03 PM

you use the speed 3 to move after a 16 grid..

16/3 = 5 1/3

so it will stop moving after the game have run 5 and 1/3 frames, but the game only do minimum 1 and 1 frame at a time, so it will continue running past 10 2/3 frames and first stop when 16 frames have run .. so i takes 3 grids before it stops

what you can do is to choose a speed that gives a whole number when you divide 16 with it.. like:

1, 2, 4, 8 and 16 .. if you don't want that then you'll have to run a code that check every step in the direction

Edited by FoxInABox, 08 May 2007 - 09:04 PM.

  • 1

#3 Nixa

Nixa

    GMC Member

  • GMC Member
  • 496 posts
  • Version:GM:Studio

Posted 08 May 2007 - 09:35 PM

event pres left:

self.x = self.x-16
self.y = self.y

event pres right:

self.x = self.x+16
self.y = self.y
event pres up:

self.x = self.x
self.y = self.y-16

event pres down:

self.x = self.x
self.y = self.y+16

you can put collision checking before moving

Edited by Nixa, 08 May 2007 - 09:35 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users