Cursgame Manual 0.2.0: Module character

Next: Module color, Previous: Module inp, Up: Top [Contents][Index]

## 5 Module character

This chapter describes the contents of the character module in detail.

### 5.1 Obj

This class is a metaclass for all stuff that can be placed on in the game. See the documentation for the abc module for more on metaclasses.

#### 5.1.1 methods

Here are all methods of the Obj class.

#### 5.1.1.1 __init__/constructor

Does nothing in your interest. Takes no arguments.

#### 5.1.1.2 move

Changes the position of the Obj by the two given arguments, relative to the current position.

#### 5.1.1.3 __str__

The return value is used for representing the Obj in the game. This is an abstract method, so you need to override it in a subclass.

#### 5.1.1.4 color

This function should return a valid curses color-code. These color codes are defined in the `cursgame.color` module. See colors.

#### 5.1.1.5 activate

This method is called if some other Obj wants to step on the field this Obj is on. You can use it to whatever. It defaults to killing the object and removing it from the game (including the action-loop if it’s on it). The return value is used to determine wether the mofing Obj should be moved or not. If you return True, the moving Obj is moved. If you return False the moving Obj stays where it was. By default True is returned, so if you step on an Obj not overriding activate you step on it and killing it. You can override it and do anything you want. You can even do nothing (for example walls do nothing except returning False). If on a Field is more than one Obj the activate method is only called on the Obj on the top.

#### 5.1.1.6 aloop

This method is called once per frame, if the Obj is placed on the action-loop. This is usually the case if you placed it with the last argument to Map.place as True.

#### 5.1.2 attributes

Here are all important attributes of the Obj.

#### 5.1.2.1 pos

This attribute contains an tuple with the coordinates of the Obj (x first item).

#### 5.1.2.2 map

This variable contains the map this Obj is on.

#### 5.1.2.3 dead

This variable is True when the Obj is dead. Note that this attribute doesn’t have any effect on Cursgame. It is only for the user.

### 5.2 Human

This class is a default human. You obviously don’t have to use this Human and can make you own that fits your needs better. It inherits from Obj. See Obj.

#### 5.2.1 methods

Here are the methods of Human

#### 5.2.1.1 __str__

returns `"@"`. See Obj.__str__.

#### 5.2.1.2 color

returns `cursgame.color.BLUE`, which means the Human is displayed blue. See Obj.color.

Next: Module color, Previous: Module inp, Up: Top [Contents][Index]