Jump to content

Phaser - help with movement/update function


ziga-miklic
 Share

Recommended Posts

Hello!

 

I just started working with Phaser (really enjoy working with it) and now that I have gone through their examples, I want to create a game like the old school Nokia Snake game (it is a tradition for me that the first game I create is the old school snake when starting working with a game framework/library :D )

 

My question is: what is the best way to create a "block like movement" - one sprite moves exactly one sprite size per update (currently using the velocity or changing the x/y position moves the sprite fluidly, because of the update ratio).

 

Do I change the update function to be triggered less frequently? Do I create a counter inside of the update function and only trigger the movement on a specific count? Or is there another more elegant solution?

 

Sorry for the wall of text :) And thank you for your help :)

 

TL;DR: how to create a non-fluid movement (one size per interval)

Link to comment
Share on other sites

Short answer:

 

1. Tile map with movement on tiles so when user press "Right" it goes from tile  1,1 (x,y)   to 1,2

 

2. Ditch physics for the moment :) Nokia Snake doesn't have one so you don't need it too

 

Also you can do the whole thing without tilemaps and with arrays.

 

Here a little jquery based Snake game:

http://jquery-snakey.googlecode.com/svn/trunk/index.html

 

I'll try to make a little example for "blocky" movement in the weekend.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...