| Classes |
Links |
| Game Manager |
Link |
| Sprite |
Link |
The Game Manager is basically the CPU of this library. Initially started the Pygame application, it manages and updates all sprites until the user quit the application.
- Make new Game Manager object
'''
Arguments
----------
width : int
width of screen
height : int
height of screen
game_directory: str
path directory to game folder. os.getcwd() is sufficient.
Returns
-------
game : GameManger
'''
from scratch_py import manager
import os
game = manager.GameManager(800, 600, os.getcwd())
- Add new background (But doesn't change to it)
Arguments
----------
image_link : str
name of new background
game.add_background_image("background1.png")
Arguments
----------
image_link : str
name of new background
game.change_background_image("background1.png")
Arguments
----------
game_title : str
new name of game
game.change_title("Game Title")
- Change if user has quit or not
Returns
-------
result : bool
tell user if it has quit or not
result = game.check_quit()
- Get current background name
Returns
-------
name : str
background's name
name = game.get_background_name()
Returns
-------
timer : int
current time
timer = game.get_timer()
- Check if certain key is hold
Arguments
---------
key: str
certain key to hold
Returns
-------
result : bool
tell if that key is hold or not
result = game.key_hold('a')
- Check if certain key is pressed but not hold
Arguments
---------
key: str
certain key to press
Returns
-------
result : bool
tell if that key is pressed or not
result = game.key_pressed('a')
- Check if certain key is released
Arguments
---------
key: str
certain key to release
Returns
-------
result : bool
tell if that key is released or not
result = game.key_released('a')
- Switch to next background image (similar to Scratch backdrop)
game.next_background_image()
Arguments
---------
link : bool
link to new background music
loop_num: int
number of loops to play the new background music
infinite if loop_num == 0
game.play_background_music('music.mp3', 0)
Arguments
---------
volume : int
new volume
game.set_background_music_volume(100)
- Stop all game and sprite sounds
game.stop_background_music()
- Update game per frame (FPS)
Sprite is basically the same Sprite from Scratch. You can move it, transform it and many more!
Arguments
---------
image_link : bool
name of the image for the new sprite
scale : float
size of image
Returns
-------
new_sprite : Sprite
the new sprite
new_sprite = game.new_sprite("image.png", 30)
- Go to a specific position
sprite.go_to(0,0)
sprite.go_to_random_position()
- Glide to a particular position
sprite.glide(100, 100, 1)
sprite.glide_to_mouse_pointer(1)
sprite.glide_to_random_position(1)
sprite.glide_to_sprite(other_Sprite, 1)
sprite.set_direction(100)
sprite.point_toward_mouse()
sprite.point_toward_sprite(other_Sprite)
# All-Around, Left-Right, None
sprite.set_rotation_style("None")
dir = sprite.get_direction()
sprite.say("Hello")
sprite.say("Hello", 2)
sprite.set_costume_after_say("image2.png")
sprite.add_costume("image2.png")
sprite.next_costume()
sprite.switch_costume("image2.png")
name = sprite.get_costume_name()
num = sprite.get_costume_number()
sprite.play_sound("music.wav")
new_clone = sprite.clone()
- Check if sprite touch something
result = sprite.touch(other_sprite)
result = sprite.touch_edge()
- Check if mouse clicked on sprite
result = sprite.mouse_clicked()
result = sprite.mouse_hovered()
- Check Key 'Space' pressed
result = game.key_hold('space')
result = game.key_pressed('space')
result - game.key_released('space')
sprite.show_box()
sprite.hide_box()