Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant functions from API #88

Merged
merged 13 commits into from
Aug 13, 2023
Merged

Remove redundant functions from API #88

merged 13 commits into from
Aug 13, 2023

Conversation

elgopher
Copy link
Owner

@elgopher elgopher commented Aug 12, 2023

To keep compatiblity with Pico-8, Pi provides a lot of redundant functions. This make API big and harder to understand. Users might be confused which function/variable should they use. Also from the Pi developer point of view - more code need to be maintained.

Pi was providing pi.Time() function in order to be compatible with Pico-8. Additionally, Pi provided pi.TimeSeconds with the same value.

I made a decision to remove redundancy from the API. This commit removes the pi.Time function, and replaces it with variable pi.Time.
@elgopher elgopher changed the title Api cleanup Api cleanup [experimental] Aug 12, 2023
@elgopher elgopher force-pushed the api-cleanup branch 3 times, most recently from 5a014ca to 315a920 Compare August 13, 2023 05:54
@elgopher elgopher changed the title Api cleanup [experimental] API cleanup [experimental] Aug 13, 2023
@elgopher elgopher changed the title API cleanup [experimental] Remove redundant functions from API [experimental] Aug 13, 2023
Pi was providing pi.Camera() and pi.CameraReset() functions in order to be compatible with Pico-8. Additionally, Pi provided pi.ScreenCamera.

I made a decision to remove redundancy from the API. This commit removes the pi.Camera() and pi.CameraReset() function. Now game developer can use pi.Camera variable instead.

I added two methods to pi.Position which can be very handy:

* Set(x,y)
* Reset()
In order to be compatible with Pico-8, Pi was resetting the clipping region in Cls() and ClsCol() functions. This is misleading and violates the single responsibility principle. That's why I decided to remove this behaviour.
@elgopher elgopher marked this pull request as ready for review August 13, 2023 09:04
@elgopher elgopher changed the title Remove redundant functions from API [experimental] Remove redundant functions from API Aug 13, 2023
@elgopher elgopher force-pushed the api-cleanup branch 2 times, most recently from c028e6f to a867370 Compare August 13, 2023 10:39
…Reset

These 5 functions are redundant. Programmer can use public variables for draw and display palette or color transparency.

This commits also renames pi.DrawPalette to pi.Pal, pi.DisplayPalette to pi.Pald, and pi.ColorTransparency to pi.Palt. Shorter names are better, especially when writing the code by hand in REPL terminal.

This commit also adds two new types: pi.PalMapping and pi.Transparency. Both provide Reset() method.
…sePos

Using functions which returns two parameters is sometimes cumbersome. That's why I removed pi.MousePos().

Another reason for removing pi.MousePos() was that there were two sources of the same information - pi.MousePosition var and pi.MousePos().
Reorganize file, so public functions are on the top.
Pi is using similar concepts to Pico-8, but not same names or same function signatures. For example: pi.Pal is a variable in Pi, but in Pico-8 it is a function.
Add info how to acquire resources object.
…i.Sget

pi.Sset and pi.Sget is used very rarely. And programmer could run pi.SprSheet().Set() instead. The effect will be the same.

pi.Pset and pi.Pget have misleading names. They should propably have names using 2 capital letters eg. PSet. After pi.Sset is removed, then I can safely use pi.Set which is great name to remember.
Use specific type name, so the user can quickly find out in the docs what are the values of given type.
This resolution is no longer possible to use for the screen size. Max is 64KB (eg 256x256).
Add type to pi.Palette var, even though it can be inferred by compiler. This is needed to generate better godoc documentation.
@elgopher elgopher merged commit 441b859 into master Aug 13, 2023
1 check passed
@elgopher elgopher deleted the api-cleanup branch August 13, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant