Directions

Angles

An actor can move in different directions. First you need to know how angles are interpreted in Miniworldmaker. Angles are independent of the orientation of the character:

../_images/movement.jpgmovement

  • 0° means a movement upwards.

  • 90° means a movement to the right..

  • 180° oder - 180° means a movement downwards.

  • -90° means a movement to the right.

The interpretation of directions corresponds to the popular programming language Scratch, see https://en.scratch-wiki.info/wiki/Direction_(value)

There is one exception: The default direction in Miniworldmaker is 0°, i.e. tokens point upwards.

Angles as Strings

Some angle sizes can also be called strings:

  • right”: is equivalent to 0°.

  • “up” is equivalent to 90°.

  • “left” is equivalent to 180°.

  • Down is equivalent to 270 degrees.

A special specification is “forward”: In contrast to the other specifications, “forward” means in the direction of the figure’s gaze. In the picture above “forward” corresponds to 0°, because the actor looks to the right.

Methods and Attributs

You can use the following functions to change the alignment of an actor:

self.direction

Sets the direction directly.

class miniworldmaker.tokens.token.Token(position=None)[source]
direction

Sets direction the token is oriented

0°: East, x degrees clock-wise otherwise You can also set the direction by String (“forward”, “up”, “down”, …

../_images/movement2.jpg

Examples

Moving in rpg-basic-example.py:

>>> def on_key_down(self, keys):
>>>    if "W" in keys:
>>>      self.point_in_direction("up")
>>>    elif "S" in keys:
>>>      self.point_in_direction("down")
>>>    elif "A" in keys:
>>>      self.point_in_direction("left")
>>>    elif "D" in keys:
>>>      self.point_in_direction("right")
>>>    self.move()

self.turn_left

Turns the actor in left direction.

class miniworldmaker.tokens.token.Token(position=None)[source]
turn_left(degrees: int = 90) → int[source]

Turns actor by degrees degrees left

Parameters

degrees – degrees in left direction

Returns

New direction

self.turn_right

Turns the actor in right direction.

class miniworldmaker.tokens.token.Token(position=None)[source]
turn_right(degrees: int = 90)[source]

Turns token by degrees degrees right

Parameters

degrees – degrees in left direction

Returns

New direction

self.flip_x

The actor rotates 180°. The figure is mirrored so that the actor is not upside down after the rotation.

class miniworldmaker.tokens.token.Token(position=None)[source]
flip_x() → int[source]

Flips the actor by 180° degrees

Examples

flip a token in Example flipthefish.py

>>>  def on_sensing_not_on_board(self):
>>>    self.move_back()
>>>    self.flip_x()