96 Pixel Games SDK¶
The 96 Pixel Games SDK
- Author:
- Sven Hecht <sven.hecht@gmail.com>
Sub Packages¶
animatedgameobject¶
-
class
gamelib.animatedgameobject.
AnimatedGameObject
(position, color1, color2=None, animationDuration=1, loop=1, algorithm=<function Linear>)[source]¶ Bases:
gamelib.gameobject.GameObject
The AnimatedGameObject is able to let a pixel animate between two colors.
-
gamelib.animatedgameobject.
getrandbits
(k) → x. Generates a long int with k random bits.¶
-
gamelib.animatedgameobject.
random
() → x in the interval [0, 1).¶
animation¶
-
class
gamelib.animation.
Animation
(startValue, endValue, duration, loop=1, algorithm=<function Linear>)[source]¶ Bases:
object
-
class
gamelib.animation.
AnimationAlgorithm
[source]¶ Bases:
object
A List of Animation Algorithms.
color¶
game¶
gameobject¶
gameobject.py: Represents an object in a game.
-
class
gamelib.gameobject.
GameObject
[source]¶ Bases:
object
The GameObject class represents an object in a game. It is mostly used as a base class for other elements that enrich it’s capabilities.
If used should be updated and drawn.
-
gamelib.gameobject.
getrandbits
(k) → x. Generates a long int with k random bits.¶
-
gamelib.gameobject.
random
() → x in the interval [0, 1).¶
keyboardcontroller¶
librgb¶
-
gamelib.librgb.
getrandbits
(k) → x. Generates a long int with k random bits.¶
-
gamelib.librgb.
random
() → x in the interval [0, 1).¶
music¶
sound¶
sprite¶
-
gamelib.sprite.
getrandbits
(k) → x. Generates a long int with k random bits.¶
-
gamelib.sprite.
random
() → x in the interval [0, 1).¶
statemachine¶
vector¶
vector.py: A simple little Vector class. Enabling basic 2D vector math.
-
class
gamelib.vector.
Vector
(x=0, y=0)[source]¶ Bases:
object
The Vector class can represent a direction or a position in 2-dimensional space
Examples
( Vector(2, 5) + Vector(3, 1.5) ).getNormalized()
Parameters: - x (number/tuple/list/Vector, Optional) – Represents the x dimension of the vector. If the first argument is a Vector, tuple or list the x and y dimensions will be initialized. The default x value is 0
- y (number, Optional) – Represents the y dimension of the vector. The default y value is 0
-
__add__
(other)[source]¶ Calculates the sum between this vector and the given value.
Examples
Vector(16, 22) + 5 => Vector(21, 27) Vector(13, 13) + Vector(7, 5) => Vector(20, 18) Vector(13, 13) + [7, 5] => Vector(20, 18) Vector(13, 13) + (7, 5) => Vector(20, 18)
Parameters: other (Vector/tuple/list/number) – the value to perform the add function with Returns: A new Vector instance containing the sum of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__div__
(other)[source]¶ Calculates the quotient between this vector and the given value.
Examples
Vector(16, 22) / 5 => Vector( 3, 4) Vector(12, 13) / Vector(6, 5) => Vector( 2, 2) Vector(12, 13) / [6, 5] => Vector( 2, 2) Vector(12, 13) / (6, 5) => Vector( 2, 2) Vector(12.0, 13.0) / (6, 5) => Vector(2.0, 2.6)
Parameters: other (Vector/tuple/list/number) – the value to perform the division function with Returns: A new Vector instance containing the quotient of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__eq__
(other)[source]¶ The Equality comparer.
Examples
Vector(6, 2) == Vector(6, 2) => True Vector(6, 2) == Vector(6, 3) => False
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__ge__
(other)[source]¶ The greater than equals comparer.
Examples
Vector(6, 2) >= Vector(5, 1) => True Vector(6, 2) >= Vector(7, 3) => False Vector(6, 2) >= Vector(6, 2) => True
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__gt__
(other)[source]¶ The greater than comparer.
Examples
Vector(6, 2) > Vector(5, 1) => True Vector(6, 2) > Vector(7, 3) => False Vector(6, 2) > Vector(6, 2) => False
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__iadd__
(other)[source]¶ Calculates the sum between this vector and the given value in place.
Examples
Vector(16, 22) += 5 => Vector(21, 27) Vector(13, 13) += Vector(7, 5) => Vector(20, 18) Vector(13, 13) += [7, 5] => Vector(20, 18) Vector(13, 13) += (7, 5) => Vector(20, 18)
Parameters: other (Vector/tuple/list/number) – the value to perform the add function with Returns: itself, containing the sum of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__idiv__
(other)[source]¶ Calculates the quotient between this vector and the given value in place.
Examples
Vector(16, 22) /= 5 => Vector( 3, 4) Vector(12, 13) /= Vector(6, 5) => Vector( 2, 2) Vector(12, 13) /= [6, 5] => Vector( 2, 2) Vector(12, 13) /= (6, 5) => Vector( 2, 2) Vector(12.0, 13.0) /= (6, 5) => Vector(2.0, 2.6)
Parameters: other (Vector/tuple/list/number) – the value to perform the division function with Returns: itself, containing the quotient of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__imul__
(other)[source]¶ Calculates the product between this vector and the given value in place.
Examples
Vector(16, 22) *= 5 => Vector(80, 110) Vector(13, 13) *= Vector(7, 5) => Vector(91, 65) Vector(13, 13) *= [7, 5] => Vector(91, 65) Vector(13, 13) *= (7, 5) => Vector(91, 65)
Parameters: other (Vector/tuple/list/number) – the value to perform the multiply function with Returns: itself, containing the product of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__ipow__
(other)[source]¶ Calculates the power of this vector by the given value in place.
Examples
Vector(6, 2) **= 5 => Vector(7776, 32) Vector(6, 2) **= 5.0 => Vector(7776.0, 32.0)
Parameters: other (number) – the value to perform the exponentiation with Returns: itself, containing the result of the calculation Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__isub__
(other)[source]¶ Calculates the difference between this vector and the given value in place.
- Examples:
- Vector(16, 22) -= 5 => Vector(11, 17) Vector(13, 13) -= Vector(7, 5) => Vector( 6, 8) Vector(13, 13) -= [7, 5] => Vector( 6, 8) Vector(13, 13) -= (7, 5) => Vector( 6, 8)
Parameters: other (Vector/tuple/list/number) – the value to perform the substract function with Returns: itself, containing the difference of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__le__
(other)[source]¶ The less than equals comparer.
Examples
Vector(6, 2) <= Vector(5, 1) => False Vector(6, 2) <= Vector(7, 3) => True Vector(6, 2) <= Vector(6, 2) => True
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__len__
()[source]¶ Calculates the magnitude of the vector.
Examples
len(Vector(1, 0)) => 1 len(Vector(0, 2)) => 2
Parameters: other (Vector) – the other Vector to compare this one to Returns: The magnitude of the vector Return type: Number
-
__lt__
(other)[source]¶ The less than comparer.
Examples
Vector(6, 2) < Vector(5, 1) => False Vector(6, 2) < Vector(7, 3) => True Vector(6, 2) < Vector(6, 2) => False
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__mul__
(other)[source]¶ Calculates the product between this vector and the given value.
Examples
Vector(16, 22) * 5 => Vector(80, 110) Vector(13, 13) * Vector(7, 5) => Vector(91, 65) Vector(13, 13) * [7, 5] => Vector(91, 65) Vector(13, 13) * (7, 5) => Vector(91, 65)
Parameters: other (Vector/tuple/list/number) – the value to perform the multiply function with Returns: A new Vector instance containing the product of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__ne__
(other)[source]¶ The Unequality comparer.
Examples
Vector(6, 2) != Vector(6, 2) => False Vector(6, 2) != Vector(6, 3) => True
Parameters: other (Vector) – the other Vector to compare this one to Returns: a bool representing the result of the comparison Return type: Boolean Raises: NotImplemented for arguments of not accepted type
-
__pow__
(other)[source]¶ Calculates the power of this vector by the given value.
Examples
Vector(6, 2) ** 5 => Vector(7776, 32) Vector(6, 2) ** 5.0 => Vector(7776.0, 32.0)
Parameters: other (number) – the value to perform the exponentiation with Returns: A new Vector instance containing the result of the calculation Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__rdiv__
(other)[source]¶ Calculates the quotient between the given value and this vector.
Examples
22.0 / Vector(16, 22) => Vector(1.375, 1.0) Vector(22.0, 25.0) / Vector(16, 5) => Vector(1.375, 5.0) [22.0, 25.0] / Vector(16, 5) => Vector(1.375, 5.0) (22.0, 25.0) / Vector(16, 5) => Vector(1.375, 5.0) (22, 25) / Vector(16, 5) => Vector(1, 5)
Parameters: other (Vector/tuple/list/number) – the value to perform the division function with Returns: A new Vector instance containing the quotient of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__rsub__
(other)[source]¶ Calculates the difference between the given value and this vector.
Examples
5 - Vector(16, 22) => Vector(-11, -17) Vector(7, 5) - Vector(13, 13) => Vector( -6, -8) [7, 5] - Vector(13, 13) => Vector( -6, -8) (7, 5) - Vector(13, 13) => Vector( -6, -8)
Parameters: other (Vector/tuple/list/number) – the value to perform the substract function with Returns: A new Vector instance containing the difference of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
__sub__
(other)[source]¶ Calculates the difference between this vector and the given value.
Examples
Vector(16, 22) - 5 => Vector(11, 17) Vector(13, 13) - Vector(7, 5) => Vector( 6, 8) Vector(13, 13) - [7, 5] => Vector( 6, 8) Vector(13, 13) - (7, 5) => Vector( 6, 8)
Parameters: other (Vector/tuple/list/number) – the value to perform the substract function with Returns: A new Vector instance containing the difference of the values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
static
angle
(v1, v2)[source]¶ Calculates the angle in Radian between 2 Vectors
Parameters: Returns: a number in radian representing the angle between the to vectors.
Return type: Number
-
static
angleDeg
(v1, v2)[source]¶ Calculates the angle in Degree between 2 Vectors
Parameters: Returns: a number in degree representing the angle between the to vectors.
Return type: Number
-
static
distance
(a, b)[source]¶ Calculates the distance between 2 Vectors
Parameters: Returns: a number representing the distance between the to vectors (if they represent points in space)
Return type: Number
-
dotproduct
(other)[source]¶ Calculates the dot product between this vector and the given value.
Parameters: other (Vector/tuple/list) – the value to perform the dot product function with Returns: A new Vector instance containing the calculated values Return type: Vector Raises: NotImplemented for arguments of not accepted type
-
getLength
()[source]¶ Calculates the magnitude of the vector.
Examples
Vector(1, 0).getLength() => 1 Vector(0, 2).getLength() => 2
Parameters: other (Vector) – the other Vector to compare this one to Returns: The magnitude of the vector Return type: Number
-
getNormalized
()[source]¶ Creates a new normalized instance of the Vector
Returns: A new instance of type Vector but normalized Return type: Vector
-
modulo
(other)[source]¶ Calculates the modulo between this vector and the given value.
Examples
Vector(16, 22).modulo( 5 ) => Vector(1, 2) Vector(13, 13).modulo( Vector(7, 5) ) => Vector(6, 3) Vector(13, 13).modulo( [7, 5] ) => Vector(6, 3) Vector(13, 13).modulo( (7, 5) ) => Vector(6, 3)
Parameters: other (Vector/tuple/list/number) – the value to perform the modulo function with Returns: A new Vector instance containing the calculated values Return type: Vector
-
static
random
(size=1)[source]¶ Creates a randomized Vector contained inside a square of the dimensions size x size.
Parameters: size (number, Optional) – Determines the max bounds of the new Random Vector. Default is 1. Returns: a new instance of type Vector Return type: Vector
-
static
randomUnitCircle
()[source]¶ Creates a randomized unit Vector that lies on the unit circle (circle of radius 1).
Returns: a new instance of type Vector Return type: Vector
-
set
(x, y)[source]¶ Updates the dimensions of the Vector.
Parameters: - x (number) – the new value for the x dimension
- y (number) – the new value for the y dimension
-
toArr
()[source]¶ Creates an array of the form [x, y]
Returns: an array representing the Vector Return type: Array
-
gamelib.vector.
getrandbits
(k) → x. Generates a long int with k random bits.¶
-
gamelib.vector.
random
() → x in the interval [0, 1).¶