Skip to content

Python interpreter and game-critical functions as a godot extension

License

Notifications You must be signed in to change notification settings

carsonburr/code_world_godot_ext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy of the godot engine with added module for code_world

link to most recent executable: https://www.dropbox.com/sh/5abcqw3idghleek/AABzjBqElM1cWP3MmvqVndzna?dl=0

Documentation

Entity

Any object in godot (read node) that we want to represent to the interpreter

Properties:
NodePath node
the path to the godot node the entity represents. For use with get_node(NodePath)
get_node_path(), set_node_path(NodePath node)
Room_Tile tile
the tile that the entity resides in
get_tile(), set_tile(Room_Tile tile)
Member functions:
void init(NodePath node, Room_Tile tile)
initializes the entity, other functions (including get/set) will not work until init is called
bool is_initialized()
check if entity is initialized
bool move_tile(int x, int y)
move the entity to another tile in the same room. returns success
bool move_tile_relative(int x, int y)
move the entity to another tile relative to current tile. returns success
bool move_tile_room(Room_Map room, int x, int y)(int x, int y)
move the entity to a tile in a new room. returns success

Room_Tile

Properties:
Room_Map room
the room that the tile resides in
get_room()
int x, y
the coordinates for the tile in the containing room
get_x(), get_y()
Entity ent
the entity in the tile, may be empty (null)
get_entity(), set_entity(Entity ent)
Member functions:
void init(NodePath node, Room_Tile tile)
initializes the tile, other functions (including get/set) will not work until init is called
bool is_initialized()
check if tile is initialized

Room_Map

Properties:
Floor_Map floor
the floor that the room resides in
get_floor()
Room_Tile** tiles
a 2d array of tiles that the room contains
get_tile(int x, int y)
int x, y
the coordinates for the room int the containing floor
get_x(), get_y()
int size_x, size_y
the dimensions for the grid of tiles that the room contains
get_size_x(), get_size_y()
bool doors[4]
stores whether or not there is a door in each direction. Uses constants up, down, left, right
get_door(int dir), set_doors(bool up, bool down, bool left, bool right)
Member functions:
void init(Floor_Map floor, int x, int y, int size_x, int size_y)
initializes the room, other functions (including get/set) will not work until init is called
bool is_initialized()
check if room is initialized

Floor_Map

Properties:
Room_Map** rooms
a 2d array of rooms that the floor contains
get_room(int x, int y)
int size_x, size_y
the dimensions for the grid of rooms that the floor contains
get_size_x(), get_size_y()
Member functions:
void init(int size_x, int size_y)
initializes the floor, other functions (including get/set) will not work until init is called
bool is_initialized()
check if floor is initialized

Interpreter

Properties:
Member functions:
bool init(String code)
initializes the interpreter with the user's code, other functions will not work until init is called. returns success
bool is_initialized()
check if interpreter is initialized
bool run()
Calls a function in the user's code named 'run()' returns success
bool finalize()
Stops the interpreter. Needed to prevent errors/memory leaks. returns success
bool is_button_pressed(int button)
Checks if the user pressed the specified button with their python code. button uses the constants up, down, left, right, use_arrow

Python Module

Use:

import cw

def run():
	#user code here. Each time the player-bot steps, this is called
Methods:
cw.press_up()
cw.press_down()
cw.press_left()
cw.press_right()
cw.press_use_arrow()
User can call these to press a virtual button input for the bot
cw.get_pos_x()
cw.get_pos_y()
gets the position of the bot in the current room
cw.get_room_x()
cw.get_room_y()
gets the x and y coordinates of the current room in the floor
bool cw.get_enemy_at(x, y)
determines if there is an enemy on the tile of the (x, y) coordinates of the room
bool cw.get_door(dir)
determines if there is a door in the current room in the specified direction. Takes "u", "d", "l", or "r" as dir
bool cw.get_door_room(str dir, x, y)
determines if there is a door in the specified (x, y) room in the specified direction. Takes "u", "d", "l", or "r" as dir

About

Python interpreter and game-critical functions as a godot extension

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published