Skip to main content

No project description provided

Project description

made by : Matthew R and William L

//////////////////////////// -----welcome to skyport----- //////////////////////////// v0.2.1(unstable)

the purpos of skyport is to:

is to be a game engine that automaticly takes care of rendering loop , file pre loading and having a few usful utilaty tools

boilerplate code :

import skyport as sp

dm = sp.Display_Manager(
    window_size=(1920,1080),
    display_size=(960,540),
    window_name="skyport test"
    )

dm.START_RENDERING_THREAD(fps=60)
while dm.running:

    dm.event_handler()

geting started :

note : skyport is not a replacement to pygame so it is good to be familiar with pygame

to start off you might want to have pygame and skyport but dont import pygame because then you will be using a separet instance of pygame from the rest of skyport instead get pygame from skyport 
import skyport as sp

pygame = sp.pygame
now you can use pygame and skyport normaly 

to create your window you will need to create a Display_Manager instance 
    display_manager = sp.Display_Manager(
        window_size=(500, 500),
        display_size=(100, 100), # the display size is the scale at which the game is ran 
        window_name="my window"
        window_ico=None # this would be a pygame.Surface or an image but we will go over this later
        force_full_screen=False # this determans if the window will start full screened
        resizable=True # if this is False then the window will not be resizable
    )
this will make a window pop up but it wont respond and that is bc the rendering thread is not on and you have to manualy manage the window in this state

one thing you can do while the window is in this state is manualy do a loading screen while your game initalizes before the renderin thread starts
import time
pygame = sp.pygame

# you will see how to use the loader father down in the README.md
loader = sp.Loader(__file__)
img = loader.read(path="C:\\Users\\matt\\source\\repos\\RSPG\\RSPG\\pt-17.png",add_to_map=True)


dm = sp.Display_Manager(
    window_size=(500,500),
    display_size=(100,100),
    window_name="my first skyport window",
    window_ico=img
)

time.sleep(10) # your game loading

# untill you start the rendering thread the window will not respond 
dm.START_RENDERING_THREAD(60)

sp.loger.output_print_data() # this line prints out everything that the engine has loged including any errors or random logs


#game loop
while dm.running:

    dm.event_handler()
    dm.tick(tps=20)
in this example the window will not respond fot 10 seconds but in that time you could init your game on a separet thread and run a loading screen (video on threading : https://www.youtube.com/watch?v=A_Z1lgZLSNc )

..... more will come in a later update ......

Display_Manager :

the display manager is made to automaticly handle the window on a separete thread so that the rendering loop can be separet from the game loop

Loader :

the loader is made to pre cache files in memory

how to make a Loader map :

{
    "path":{"value":null,"type":null},
    ...
}
in the Loader_map format there are a couple of types and each do difrent things.
TYPES:
    - "r" / "replace" : this type will read the file from where "value" sais to rather than the og path. example : ```json "path/jeff.png":{"value":"replacement_path.jpg,"type":"r"} ```
    - "list" : this mode allows you to load an entire file under 1 name by havig "path" as the folder dir and then in "value" you would place a list of files you would like to load. example : ```json "path/dave":{"value":["bob.png","sam/frend.json"...],"type":"list"} ``` how you would acses this is : loader_instance.read(path)[index]
    - "dict" : this type allows you to load an entire folder under one name slightly dif. the "path" would be the folder dir just like in "list" but this time "value" is filled with a dict of {"name":"file"} instead of a list. example ```json "assets/rand":{"value":{"dave":"dave.png","bob":"idk/jeff.csv"},"type":"dict} ``` and how you would acses it is by : loader_instance.read(path)[name]
    - null : this is the defalt and it dose not matter what the "type" is. this mode will load the "path" to the Loader map and how you would acses the file would be : loader_instance.read(path)

FULL FILE EXAMPLE:
{
    "assets/jeff.png":{
        "value":null,
        "type":null
    },
    "assets/rand/":{
        "value":[
            "ball.json",
            "ball.png"
        ],
    "type":"list"
    },
    "assets/icons": {
        "type": "dict",
        "value": {
            "button1": "button_play.png",
            "coin": "coin.png",
            "button2": "button2.png"
        }
    },
    "assets/files/data.png":{
        "value":"texture_pack/file/data.png",
        "type":"replace"
    }
}

how to use Loader in code :

the Loader is simple, you first create an instance and pass in __file__ so that the Loader can resolve realative paths then you can pre load the Loader with a Loader map (this is optional) then you can use the Loader to read files whether they have been pre caches or not. example code :
import skyport as sp

# you need to pass in __file__ so the Loader knows where to do realative paths
loader = sp.Loader(__file__)
# (optional) you can pre load all the files you want into the Loader so you dont have to get them later
loader.load_from_map("loader_map_test1.json")

# to read the content of the file whether the Loader has pre loaded it or not you can call read()
file_data = loader.read(path="my_path/image.png",add_to_map=True)
# this method allows you to create more conviniant names for your pre loaded files
loader.create_alias("my_path/image.png","image")
# this returns the dict of supported types and there file handlers
loader.get_supported_types()
# you can add your own file types for the loader to support if the loader dose not already suport them 
loader.add_new_file_handler(".idk",lambda path : open(path,"r"))
# this is for when u have 1 loaders or 2 name:file maps
loader.join_maps(map_a=,map_b=)
# this is for turning any path into an abs path
loader.resolve_path(path)
# this is for saving files that are in the Loader
loader.save(path,map_key) 
# this is for saving the curent in memory file map
loader.save_map(path,map)
# this is for getting the Loader map
loader.get_map()
# this is for setting the Loader map
loader.set_map(map)
there are more methods in the loader but they are not mentiond heare

how to handle supported / unsuported file types :

there are 2 decorators for adding file type support Load_file and Save_file
Load file takes in a lamda that takes in a file obj and will load it and the save file takes in a lambda that takes in a file obj and the data to save for example:
    ".txt": Load_file(lambda f: f.read()),
    ".json": Load_file(json.load)
and for saving :
    ".jpeg": lambda p, d: pygame.image.save(d, p),
    ".txt": Save_file(lambda f, d: f.write(str(d))) 

Util :

this is a utilaty class that holds random and potentialy usefull methods sutch as

  • get_angle_and_dist(self,x1:"int",y1:"int",x:"int",y:"int")
  • pryoraty(self,a=None,b=None) : this function will return a if there is an a
  • snap_cords_in_bounds(self,x:"int",y:"int",max_x:"int",max_y:"int",min_x:"int"=0,min_y:"int"=0) : this snaps cords in side of a rect arya
  • couculate_dx_dy(self,dist:"int",angle:"float")
  • couculate_angle_dist(self,dx:"int",dy:"int")
  • play_sound(self,soud_obj:"pygame.mixer.Sound", volume=0.5,loops=0)
  • play_sound_from_point(self,pf,sound_pos:list,listener_pos:list,volume:float=0.5,loops=0,distance_fade=0.5)
  • warp_image(self,image:"pygame.Surface",sizex:"int",sizey:"int",angle:"float")
  • rotate_image(self,image:"pygame.Surface",angle:"float")
  • scale_image(self,image:"pygame.Surface",sizex:"int",sizey:"int")
  • color_swap(self,surface: 'pygame.Surface', old_color: tuple, new_color: tuple) -> 'pygame.Surface' how do use the Util class :
import skyport as sp

util = sp.Util()

a = util.pryoraty(None,2) # a will be 2

print(a)

Delta_timer :

this is for getting the delta time between the curent call of get_dt() and the last one (there is one method -> get_dt())

Camra :

the Camra is a spesial chunk baced map renderer that can efficiently render large 2d maps (more documentation will come later)

Chunk :

this class us used by the Camra class to render large 2d maps (more documentation will come later)

dev_info: email:matthew.le.robins+proj@gmail.com (plz only email if u have found a bug and a good way to fix it and plz ensure i have a way to contact you about you suggested changes or requests)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skyport_engine-0.2.2.tar.gz (1.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skyport_engine-0.2.2-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file skyport_engine-0.2.2.tar.gz.

File metadata

  • Download URL: skyport_engine-0.2.2.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for skyport_engine-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3b2e4a44c36ffc79fb3d33191bff1963989b4f47d1ca034ad4857be024f81057
MD5 8e4a4870e0578aafe758c477b9454e33
BLAKE2b-256 b3692f653ee020719b85c4115217afb6888cd3dfeed9cea1e2bbb1dc7a8fa562

See more details on using hashes here.

File details

Details for the file skyport_engine-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: skyport_engine-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for skyport_engine-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 414ef161818ea44deb2dd5c6ca561ed3609db957ef1254efb0001bc530acae2e
MD5 693a709807491594ed4489303eec5b51
BLAKE2b-256 9cb1d463ee8bbd1016d0c1d06b8d14850604661b6aef7ff77973cde613c21e79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page