Skip to content

Commit

Permalink
Update 2.2
Browse files Browse the repository at this point in the history
The only backward incompatible change in this version is the change in the SharkG for loop from a C like loop (for x: int = 0, x < y, x++ do ...) to a range based style (for x to y do ...).
Many bugfixes and small improvements on the android, flash and HTML5 ports of Shark and SharkG,
  • Loading branch information
shogundevel committed Jun 4, 2023
1 parent 3f7dd33 commit e0a76d2
Show file tree
Hide file tree
Showing 136 changed files with 2,527 additions and 272 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ To run sharkmake cd to the directory containing the make file and type '> shark

You can request sharkmake to run one or more particular tags of a make file by passing their names as arguments. If no tag is specified the whole make file is executed from start to end.

## Gameshark Howto
## SharkGame Howto

To compile and run a gameshark project cd to the project's root directory and type the following commands:
To compile and run a SharkGame project cd to the project's root directory and type the following commands:

> shark tool build src/main.shk bin/game.shar
> gameshark ./
> sharkgame ./
The first command builds the game binary and the second executes it.

Expand Down Expand Up @@ -284,7 +284,7 @@ To link your program against the system library copy the generated out/system.py

> shark tool link py my-python-object.py main my-python-program.py system.py
To run a GS based game in python you will need to install the pygame library, compile the pygameshark library from source and link it 'correctly' against your game code.
To run a GS based game in python you will need to install the pygame library, compile the pysharkgame library from source and link it 'correctly' against your game code.

First install pygame:

Expand All @@ -296,9 +296,9 @@ Next cd to the shark SDK root directory and type...
...to build the system library and...

> shark tool compile py lib/libpygameshark/shark.shk out/shark.py
> shark tool compile py lib/libpysharkgame/shark.shk out/shark.py
...to build the gameshark library.
...to build the sharkgame library.

Now cd to your game's root directory and type:

Expand Down Expand Up @@ -326,11 +326,11 @@ var console

console::log("Hi.")

To run a GS based game in HTML5 you will need to compile the htmlgameshark library from source and link it 'correctly' against your game code.
To run a GS based game in HTML5 you will need to compile the htmlsharkgame library from source and link it 'correctly' against your game code.

First cd to the shark SDK root directory and type the following to build the gameshark library:
First cd to the shark SDK root directory and type the following to build the sharkgame library:

> shark tool compile js lib/libhtmlgameshark/shark.shk out/shark.js
> shark tool compile js lib/libhtmlsharkgame/shark.shk out/shark.js
Now cd to your game's root directory and type:

Expand Down Expand Up @@ -382,11 +382,11 @@ To link your program against the system library copy the generated out/system.lu

To port a GS game to Ren'Py start by launching renpy and creating a new empty project, then replace the generated 'game/script.rpy' with the file 'template/script.rpy' found in the shark SDK directory.

Next compile the shark system library and the 'renpygameshark' library using the 'rpy' target of the compiler:
Next compile the shark system library and the 'renpysharkgame' library using the 'rpy' target of the compiler:

> shark tool compile rpy lib/libpythonsystem/system.shk out/system.rpy
> shark tool compile rpy lib/librenpygameshark/shark.shk out/shark.rpy
> shark tool compile rpy lib/librenpysharkgame/shark.shk out/shark.rpy
Copy those files to your game's directory and you've got a basic renpy environment to run your game code.

Expand All @@ -396,7 +396,7 @@ Now, to compile your game to renpy source code cd to your game's root directory
Now copy the generated bin/game.rpy along with your game's /asset folder to your renpy game's directoy, and that's it. Launch your game to test it.

## Gameshark Howto (SharkG)
## SharkGame Howto (SharkG)

Building a game using the sharkgame library is not hard. All games should have an /asset directory to store images and fonts, the game executable is usually finding that directory by assuming it's placed in the same directory where it got called.

Expand Down
Binary file modified bin/edit
Binary file not shown.
33 changes: 33 additions & 0 deletions bin/include/shark.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

import "shark/asset.api"
import "shark/event.api"
import "shark/font.api"
import "shark/main.api"
import "shark/persistent.api"
import "shark/screen.api"
import "shark/texture.api"
37 changes: 37 additions & 0 deletions bin/include/shark/asset.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

import "shark/texture.api"
import "shark/font.api"

# signals that an asset was not found
var ERR_ASSET_NOT_FOUND: int

# loads the texture 'path' relative to the /asset directory
function load_texture(path: str) -> texture

# loads the font 'path' relative to the /asset directory
function load_font(path: str, size: int, color: int) -> font
58 changes: 58 additions & 0 deletions bin/include/shark/event.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

# numeric constant codes for input event types
# see the prototype of 'event' in shark/main.api

# no event
# never used in practice
var E_NONE: int

# signals pressing, moving and releasing of the single touch display/mouse
# when recieving one of these, the 'x' and 'y' arguments are the absolute screen location of the event
var E_PRESS: int
var E_MOVE: int
var E_RELEASE: int

# signals pressing and releasing analogic buttons
# UP, DOWN, LEFT and RIGHT are the D-Pad
# X and Y are usually the Accept and Cancel buttons (but you can use them for whatever you want)
var E_PRESS_UP: int
var E_PRESS_DOWN: int
var E_PRESS_LEFT: int
var E_PRESS_RIGHT: int
var E_PRESS_X: int
var E_PRESS_Y: int
var E_REL_UP: int
var E_REL_DOWN: int
var E_REL_LEFT: int
var E_REL_RIGHT: int
var E_REL_X: int
var E_REL_Y: int

# NOTE: It's important (unless you're making a game for certain platforms only) that
# a game can interact with the user using both the touch screen and analogic buttons
# as some platforms will only provide one of the two.
34 changes: 34 additions & 0 deletions bin/include/shark/font.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

# a font used to render text
# fonts are created with the load_font call from shark/asset.api
class font (object)
# frees this font
function free()

# gets the height (point size) of this font
function get_height()
41 changes: 41 additions & 0 deletions bin/include/shark/main.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

# this file contains the prototypes of the main functions that compose a game
# you have to implement all of them to have a working game

# called on game start to intialize its state
function launch()

# called on each event with the event information
# 'type' is the event type, 'x' and 'y' are the screen coordinates of the event
function event(type: int, x: int, y: int)

# called on each game cycle to update the game's state
function update()

# called on each game cycle to render the game on screen
function render()
32 changes: 32 additions & 0 deletions bin/include/shark/persistent.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

import "system/io.api"

# gets the save file for this application
# mode can be 'w' for writing or 'r' for reading
# if 'r' mode is requested and no save data is available null is returned
function get_save_file(mode: char) -> FILE
41 changes: 41 additions & 0 deletions bin/include/shark/screen.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

import "shark/texture.api"
import "shark/font.api"

# Draws the texture 'text' into the screen at position x, y.
# The drawing is done by taking the x and y argument and drawing the given texture by placing its top-left corner at the x, y position.
function draw(text: texture, x: int, y: int)

# Draws the texture 'text' into the screen applying the given transformations.
# The texture is drawn centered at (x, y), position is computed by adding origin_x and origin_y coordinates to the center of the texture, rotating it rotation degrees clockwise and scaling it by the (scale_x, scale_y) vector.
function draw_ex(text: texture, x: int, y: int,
origin_x: int, origin_y: int,
rotation: float, scale_x: float, scale_y: float)

# Draws the text string 'text' using the given font into the screen at position x, y.
function draw_text(text: str, font_object: font, x: int, y: int)
37 changes: 37 additions & 0 deletions bin/include/shark/texture.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
###############################################################################
### Copyright ##################################################################
##
## Copyright 2022 Daniel Alvarez <shogundevel@gmail.com>
##
## Permission is hereby granted, free of charge, to any person
## obtaining a copy of this software and associated documentation files
## (the "Software"), to deal in the Software without restriction,
## including without limitation the rights to use, copy, modify, merge,
## publish, distribute, sublicense, and/or sell copies of the Software,
## and to permit persons to whom the Software is furnished to do so,
## subject to the following conditions:
##
## The above copyright notice and this permission notice shall be
## included in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
## EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
## MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
## IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
## CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
## TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
## SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
##
################################################################################

# a texture that can be drawn into the screen
# textures are created with the load_texture call from shark/asset.api
class texture (object)
# frees this texture
function free()

# gets the width of this texture
function get_size_x() -> int

# gets the height of this texture
function get_size_y() -> int

0 comments on commit e0a76d2

Please sign in to comment.