The moving speed should be a float value like 0.2f. To calculate the total moving amount, multiply the speed with the current frame delta:
1
| float speed = 0.2f * delta; |
After that, you could move your tile (or game object, whatever) in any direction. After reaching the next tile cell, you can stop the movement (in a tile based map). Or how does your "tile" game look like?
Thank you guys for fast answers. I will try what you recommend. I don`t think the game lags. I paint only tiles that are visible in view field (1280x560) and tiles that positionX is smaller than 0 are removed and not updated. My game is a scrolling game.There is character on fixed location who is jumping,sliding and picking an objects on grid. Grid is moving left in negative direction.I tried also with removing a background, painting tiles like rectangle and make very small grid with only one visible object and is still the same, tiles are moving same way. My game structure:
In
tile class is main constructor (public Tile() {}) where are defined positionX, positionY, speed and type (image) of moving object. Than there is a collision method and update method where I update position with
(where speed is -10)
In
main applet class there is an ArrayList for tiles and many methods. One of them is method which reads from txt file and create tiles. Than method for updating ArrayList of tiles and for tiles painting.
I dont have any FPS counter inside game, but FRAPS (tool for recording clips inside games) is showing me that in this applet FPS are between 109 and 111. With pause of 10ms i have 200 FPS and tiles are moving same way. It is not annyoing problem but still want to fix it.

Tile move like: --------

I want: _____________
