Wrap the world around...

Hi Everyone,

This may be very straight forward but I cant seem to find any quick reference.
If I were to create a retro game, e.g snake something down those lines… how could I wrap the world around such that if the player runs of one side he will appear on the other side of the screen/map?

Is there a GUI setting or is this commonly done in Python? I used to do a bit in 2.47, lost in the new interface atm lol

Thanks in advance :slight_smile:
Steve

You can play with the positions:
if player position in> max position: player position = min position.

You can play with the positions:
if player position in> max position: player position = min position.

isnt it better to use worldposition instead of position? anyway i got a teleport script in the resource section, look at that, place a port at one side and 1 at the other :slight_smile:

Thanks people, I thought it was something down those directions…

Here’s the code for anyone who is interested… it is pretty basic/unelegant/ugly mind


import GameLogic
cont = GameLogic.getCurrentController()
ob = cont.owner


#near or touch sensor on an empty or object linked to Teleport.py
sensor = cont.sensors["Teleport"]


if sensor.positive:
    if ob.worldPosition[0] < 3: # x - left edge
        ob.worldPosition[0] = 91
    elif ob.worldPosition[0] > 89: # over right edge
        ob.worldPosition[0] = 1 
    elif ob.worldPosition[1] < 5: # y - bottom edge
        ob.worldPosition[1] = 53
    elif ob.worldPosition[1] > 51: # over top edge
        ob.worldPosition[1] = 0

As you guys mentioned, just set up some planes with a specific property in game logic. Then in the player use “near” sensors to determine whether to trigger this script.

Merci people