Create console games
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Issues
You can report issues in the wingsys GitHub repository.
Installation
pip install wingsys
What's new
screen.__init__has now thecheckIfCharargument.screen.__init__has now thecheckIfColorargument.screen.__init__has now thecheckIfBorderargument.- All arguments named
forecolorare now namedforeColor. - All arguments named
backcolorare now namedbackColor. - All arguments named
stdcharare now namedstdChar. - All variables named
currxare now namedcurrX. - All variables named
curryare now namedcurrY.
Documentation
screen
def __init__(self, foreColor = "WHITE", backColor = "BLACK", width = 32, height = 16, border = ["-", "|", "#", "#", "#", "#"], stdChar = " ", checkIfChar = True, checkIfColor = True, checkIfBorder = True)
screen = wingsys.screen()
Creates a new screen.
foreColor: The text color of the screen.
backColor: The background color of the screen.
width: The width of the screen.
height: The height of the screen.
border: The border of the screen (see Custom Borders).
stdChar: The character to fill the screen with.
checkIfChar: If it should check if stdChar is not a single char, returning SyntaxError("stdChar is not a single char").
checkIfColor: If it should check if foreColor and backColor are not colorama.Fore and colorama.Back respectively, returning SyntaxError(f"{foreColor} is not a valid attribute in colorama.ansi.ansiFore") and SyntaxError(f"{backColor} is not a valid attribute in colorama.ansi.ansiBack").
checkIfBorder: If it should check if any element of border is not a single char, returning SyntaxError(f"border[{index}] is not a single char").
def update(self, clear = True)
screen.update()
Shows the screen to the console and clears the screen if clear is set to True.
clear: Setting this to True will also clear the console before showing the screen.
def fillChar(self, char)
screen.fillChar("#")
Fills the screen with a character. The color remains unchanged.
char: The character to fill the screen with.
def fillColor(self, fore, back)
screen.fillColor("RED", "GREEN")
Changes the screen color. The characters remain unchanged.
fore: The text color.
back: The background color.
def fill(self, char, fore, back)
screen.fill("#", "RED", "GREEN")
Fills the screen with a colored character.
char: The character to fill the screen with.
fore: The character's color.
back: The background color.
def coordsToIndex(self, x, y)
index = screen.coordsToIndex(10, 10)
Converts coordinates to the corresponding index (see Coordinates and Indexes).
x: The X position.
y: The Y position.
def indexToCoords(self, index)
x, y = screen.indexToCoords(23)
Converts an index to the corresponding coordinates (see Coordinates and Indexes).
index: The index.
setPixel
def byCoords(screen, x, y, value)
wingsys.setPixel.byCoords(screen, 10, 10, "#")
Sets the given coordinate to the value (see Coordinates and Indexes).
screen: The screen to write to.
x: The X coordinate.
y: The Y coordinate.
value: The value the pixel should be set to.
def byIndex(screen, index, value)
wingsys.setPixel.byIndex(screen, 23, "#")
Sets the given index to the value (see Coordinates and Indexes).
screen: The screen to write to.
index: The index.
value: The value the pixel should be set to.
getPixel
def byCoords(screen, x, y)
pixel = wingsys.getPixel.byCoords(screen, 10, 10)
Returns the value of the given coordinate (see Coordinates and Indexes).
screen: The screen.
x: The X coordinate.
y: The Y coordinate.
def byIndex(screen, index, value)
pixel = wingsys.getPixel.byIndex(screen, 23, "#")
Returns the value of the given index (see Coordinates and Indexes).
screen: The screen.
index: The index.
setPixelColor
def byCoords(screen, x, y, fore, back)
wingsys.setPixelColor.byCoords(screen, 10, 10, "RED", "GREEN")
Sets the given coordinate's color to fore and back (see Coordinates and Indexes).
screen: The screen to write to.
x: The X coordinate.
y: The Y coordinate.
fore: The text color.
back: The background color.
def byIndex(screen, index, fore, back)
wingsys.setPixelColor.byIndex(screen, 23, "RED", "GREEN")
Sets the given index's color to the value (see Coordinates and Indexes).
screen: The screen to write to.
index: The index.
fore: The text color.
back: The background color.
getPixelColor
def byCoords(screen, x, y)
wingsys.getPixelColor.byCoords(screen, 10, 10)
Gets the given coordinate's color (fore + back) (see Coordinates and Indexes).
screen: The screen.
x: The X coordinate.
y: The Y coordinate.
def byIndex(screen, index)
wingsys.getPixelColor.byIndex(screen, 23)
Gets the given index's color (fore + back) (see Coordinates and Indexes).
screen: The screen.
index: The index.
keys
def waitForKeys(key1 = "none", key2 = "none", key3 = "none", key4 = "none", key5 = "none", key6 = "none", key7 = "none", key8 = "none", key9 = "none", key10 = "none", key11 = "none", key12 = "none", key13 = "none", key14 = "none", key15 = "none", key16 = "none")
key = wingsys.keys.waitForKeys("enter", "space", "up", "down", "left", "right", "w", "s", "a", "d")
Waits for any key that is in the arguments and returns the argument position (example: ("enter", "space") if you press space it returns 2 but if you press enter it returns 1).
key1 ... key16: The key and its return code.
sprite
def __init__(self, x, y, char, fore, back)
player = wingsys.sprite(10, 10, "X", "BLUE", "MAGENTA")
Creates a new sprite.
x: The X position.
y: The Y position.
char: The sprite's character.
fore: The char's color.
back: The sprite's background color.
def update(self, screen, update, clear)
player.update(screen)
Draws the sprite in the screen.
screen: where to update the sprite.
update: If it should automatically update the screen.
clear: If it should clear the screen before updating. This will not do anything if update is set to false.
def setChar(self, char)
player.setChar("+")
Sets the sprite's char to the given value.
char: The char.
def setPos(self, x, y)
player.setPos(11, 11)
Sets the player's position.
x: The X coordinate.
y: The Y coordinate.
def changePos(self, x, y)
player.changePos(1, -1)
Changes the sprite's position. (x += x, y += y)
x: The X coordinate.
y: The Y coordinate.
def setX(self, x)
player.setX(11)
Sets the sprite's X position.
x: The X coordinate.
def setY(self, y)
player.setY(11)
Sets the sprite's Y position.
y: The Y coordinate.
def changeX(self, x)
player.changeX(1)
Changes the sprite's X position.
x: The X coordinate.
def changeY(self, y)
player.changeY(-1)
Changes the sprite's Y position.
y: The Y coordinate.
def setColor(self, fore, back)
player.setColor("BLUE", "MAGENTA")
Sets the sprite's color.
fore: The sprite's color.
back: The sprite's background color.
console
def clear()
console.clear()
Clears the console.
text
def write(screen: screen, text: str, x, y, fore, back, update = True, clear = True)
text.write(screen, "Hello World!", 0, 0, "BLACK", "WHITE")
Writes text to the screen.
screen: Where to write the text.
text: The text to write.
x: The X coordinate.
y: The Y coordinate.
fore: The text's color.
back: The background color.
update: If it should automatically update the screen.
clear: If it should clear the screen before updating. This will not do anything if update is set to false.
Coordinates and Indexes
The screen uses 2 ways to specify a position: coordinates (x, y) and indexes (index).
The coordinates use the x and y positions to work.
For example:
############
# #
# X #
# #
# #
# #
############
X has coordinates (2, 2).
The index is different. It directly uses the X's position in the screen list.
X has index 12.
This is how you calculate the index:
#######
#01234#
#56789#
#######
Custom Borders
The screen's border can be edited. This is how the border is printed around the screen content.
scr = wingsys.screen(border=["1", "2", "3", "4", "5", "6"], width=10, height=5)
311111111114
2 2
2 2
2 2
2 2
2 2
511111111116
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wingsys-0.4-py3-none-any.whl.
File metadata
- Download URL: wingsys-0.4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56115b8719d470747dae131bca20b36e9d8af23db2063cc9a7547af14c0d7a62
|
|
| MD5 |
1177bfc524bf297b4aecaa72d223a266
|
|
| BLAKE2b-256 |
2013d8992fd4015bd04a90b9ba27738f041e70d262d496d83755e028b7cf9e2a
|