Hey BPR, your scripts are looking a lot more readable these days but I still think it’s a good idea to give meaningful names to the text files rather than gamelogicsimple.py, just makes it easier to understand which text blocks are doing what.
I like the effect, it could be used to make an interesting background or title screen with some more interesting particles.
If you’re moving things in a grid you probably don’t need to use collisions, you can just work with co-ordinates.
Say your start point is [0, 0, 0] then you want to move to [0, 1, 0] you can move the object a little at a time until it reaches where it’s supposed to be going.
I use a python class for grid movement, which is given a start point and an end point and it lerps between them using a timer. The great thing about this is that you can pick up the class, get the state of the timer, start and end points and store it for a saved game. Loading is easy, just feed back the points and the timer progress and it will continue from where it left off.
import mathutils
class MoveMe(object):
def __init__(self, game_object, start, end, speed, timer=0.0):
self.game_object = game_object
self.start = start
self.end = end
self.speed = speed
self.timer = timer
self.done = False
def update(self):
self.game_object.worldPosition = self.start.lerp(self.end, self.timer)
self.timer += self.speed
if self.timer >= 1.0:
self.done = True
def move_an_object(cont):
own = cont.owner
if "mover" not in own:
start_point = mathutils.Vector(0.0, 1.0, 0.0)
end_point = mathutils.Vector(0.0, 2.0, 0.0)
own["mover"] = MoveMe(own, start_point, end_point, 0.002)
else:
if not own["mover"].done:
own["mover"].update()
A similar class can be used for rotations and other transformations so your game objects can be recorded in position, saved and then reloaded next time you pick up the game.
I use grid based movement for most of my games.