spx - A 2D Game Engine for learning Go+

Overview

spx - A 2D Game Engine for learning Go+

Build Status Go Report Card GitHub release Language GoDoc

Tutorials

How to run spx tutorials?

tutorial/01-Weather

Screen Shot1 Screen Shot2

Through this example you can learn how to listen events and do somethings.

Here is some codes in Kai.spx:

onStart => {
	setCostume "kai-a"
	play recordingWhere
	say "Where do you come from?", 2
	broadcast "1"
}

onMsg "2", => {
	play recordingCountry
	say "What's the climate like in your country?", 3
	broadcast "3"
}

onMsg "4", => {
	play recordingBest
	say "Which seasons do you like best?", 3
	broadcast "5"
}

We call onStart and onMsg to listen events. onStart is called when the program is started. And onMsg is called when someone calls broadcast to broadcast a message.

When the program starts, Kai says Where do you come from?, and then broadcasts the message 1. Who will recieve this message? Let's see codes in Jaime.spx:

onMsg "1", => {
	play recordingComeFrom
	say "I come from England.", 2
	broadcast "2"
}

onMsg "3", => {
	play recordingMild
	say "It's mild, but it's not always pleasant.", 4
	# ...
	broadcast "4"
}

Yes, Jaime recieves the message 1 and says I come from England.. Then he broadcasts the message 2. Kai recieves it and says What's the climate like in your country?.

The following procedures are very similar. In this way you can implement dialogues between multiple actors.

tutorial/02-Dragon

Screen Shot1

Through this example you can learn how to define variables and show them on the stage.

Here is all the codes of Dragon:

var (
	score int
)

onStart => {
	score = 0
	for {
		turn rand(-30, 30)
		step 5
		if touching("Shark") {
			score++
			play chomp, true
			step -100
		}
	}
}

We define a variable named score for Dragon. After the program starts, it moves randomly. And every time it touches Shark, it gains one score.

How to show the score on the stage? You don't need write code, just add a stageMonitor object into resources/index.json:

{
  "zorder": [
    {
      "type": "stageMonitor",
      "target": "Dragon",
      "val": "getVar:score",
      "color": 15629590,
      "label": "score",
      "mode": 1,
      "x": 5,
      "y": 5,
      "visible": true
    }
  ]
}
Comments
Releases(v1.0.0-rc6)
  • v1.0.0-rc6(May 30, 2022)

  • v1.0.0-rc5(Jan 5, 2022)

  • v1.0.0-rc4(Dec 20, 2021)

  • v1.0.0-rc3.3(Dec 11, 2021)

    changes:

    • shader add liner filter
    • remove grid unit
    • fix: turnto shortest path
    • fix: anim stop bug
    • fixWorldRange: lock the sprite in world range
    • fix map size bug
    • fix: background default white
    • fix run for wasm
    • mouse input for mobile
    • spx.Exit
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-rc2.2(Dec 5, 2021)

    new features:

    • high-efficiency pixel collisions
    • sprite.think
    • sprite.width/height => costumeWidth/Height
    • sprite.bounds
    • sprite.pixel(x, y)
    • sprite.touchingColor
    • sprite.setRotationStyle
    • sprite.setEffect/changeEffect: ColorEffect/BrightnessEffect
    • sprite.clearGraphEffects
    • sprite.stop also can stop onTick events
    • sprite.glide with animation
    • onLoaded when sprite.reload
    • add conf.ScreenshotKey
    • volume/setVolume/changeVolume
    • add map.mode/width/height
    • add window resize
    • tutorial/00-Blank
    • tutorial/00-Hello
    • wrapper mobile mouse events
    • assets for mobile support (setupWorkDir)
    • support mobile compile (ios/android)

    changes:

    • game.reset: Stop(AllOtherScripts)
    • config: currentCostumeIndex => costumeIndex/sceneIndex; costumes => scenes
    • config: bitmapResolution = 1 in default
    • reload bugfix: sprite.dying state
    • sprite.touching bugfix
    • can removeFromList many times
    • sprite in world range
    • game "stepUnit" change to map.gridUnit
    • window resize not change world map
    • remove reiszeWindow in layout method (to fix draw crash)
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta11(Dec 5, 2021)

    NOTE: This is an unstable release. Please use spx v1.0.0-rc1 in your product.

    new features:

    • sprite.touchingColor
    • sprite.setEffect/changeEffect: ColorEffect/BrightnessEffect
    • sprite.clearGraphEffects
    • sprite.stop also can stop onTick events
    • sprite.glide with animation
    • volume/setVolume/changeVolume
    • add map.mode/width/height
    • add window resize
    • add ios complie
    • tutorial/00-Blank
    • tutorial/00-Hello

    changes:

    • config: currentCostumeIndex => costumeIndex/sceneIndex; costumes => scenes
    • config: bitmapResolution = 1 in default
    • reload bugfix: sprite.dying state
    • sprite.bound => bounds
    • sprite.touching bugfix
    • can removeFromList many times
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta9(Dec 2, 2021)

    NOTE: This is an unstable release. Please use spx v1.0.0-rc1 in your product.

    new features:

    • wrapper mobile mouse events (in beta stage).
    • high-efficiency pixel collisions
    • add spx mobile complie
    • sprite.think
    • sprite.width/height => costumeWidth/Height
    • sprite.bound
    • sprite.pixel(x, y)
    • onLoaded when sprite.reload
    • add conf.ScreenshotKey

    changes:

    • game.reset: Stop(AllOtherScripts)
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-rc1(Dec 1, 2021)

  • v1.0.0-beta5(Nov 28, 2021)

    changes:

    • fix camera hit bug
    • Camera.on: bugfix
    • mv AircraftWar => https://github.com/goplus/AircraftWar
    • FlappyBird: https://github.com/goplus/FlappyBird
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta4(Nov 27, 2021)

  • v1.0.0-beta3(Nov 25, 2021)

    NOTE: This version has a hotfix patch. download spx-v1.0.0-beta4 please.

    new features:

    • Stop(kind = All | AllSprites | ThisSprite | ThisScript | OtherScriptsInSprite)

    changes:

    • game.Clear => EraseAll
    • sprite.Cloned = sprite.IsCloned
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta2(Nov 22, 2021)

    new features:

    • OnTouched
    • startTick, currentTPS (for internal use)
    • anim module use game event tick
    • add global default stepUnit
    • game.prevScene; sprite.gotoBack/glide(obj, secs)

    changes:

    • add HelloSpx in README
    • fix: the animated BUG cannot be completed when the canvas FPS is too low
    • fix: change image texture to linear
    Source code(tar.gz)
    Source code(zip)
  • v1.0.0-beta1(Nov 17, 2021)

  • v0.9.9(Nov 15, 2021)

    new features:

    • game.Reload index: allow indexFile or io.Reader
    • sprite.Width/Height()
    • refactor animation: support Frame/Move/Turn animation
    • use eventTick to support animation

    changes:

    • syncCall for onTurning/onMoving
    • rm createThread/abortThread
    • reload: recover the attributes of all sprites
    Source code(tar.gz)
    Source code(zip)
  • v0.9.8(Nov 10, 2021)

  • v0.9.7(Nov 9, 2021)

  • v0.9.6(Nov 7, 2021)

  • v0.9.5(Nov 4, 2021)

    new features:

    • allow define Sprite in index.gmx by using *Sprite or []*Sprite.
    • sprite.Step/Move() methods support int parameter

    changes:

    • bugfix: objectPos/Touching spriteObj
    Source code(tar.gz)
    Source code(zip)
  • v0.9.3(Nov 1, 2021)

    new features:

    • turn degree: compatible to scratch (not to code monkey)
    • sprite.Turn(ti *spx.TurningInfo)

    changes:

    • res.json: rename faceLeft => faceRight
    • test: TurnToMouse, TurnHeading, TurnTogether, Bullet
    • share test/res images
    Source code(tar.gz)
    Source code(zip)
  • v0.9.2(Oct 31, 2021)

  • v0.9.1(Oct 29, 2021)

    features:

    • sprite.Touching EdgeLeft/Top/Right/Bottom
    • onMoving support mi.StopMoving
    • tutorial/11-Dinosaur

    changes:

    • typo: addStore => addScore
    • gop v1.0.17
    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Oct 18, 2021)

    new features:

    • support costumeMPSet (multipart costumeSet)
    • test/Dinosaur
    • internal/gdi: add canvas backend --tags canvas

    changes:

    • tutorial/03-Clone: use Calf instead of Cat
    • refactor tutorial/09-AircraftWar
    • optimization: monitor drawRoundRect cached
    Source code(tar.gz)
    Source code(zip)
  • v0.8.11(Oct 12, 2021)

  • v0.8.9(Oct 8, 2021)

  • v0.8.8(Oct 7, 2021)

    new features:

    • Gopt_Game_Run: resource can be a string or fs.Dir object
    • Gopt_Game_Run: support OnLoaded event
    • MovingInfo.Dx/Dy

    changes:

    • gop v1.0.10: gmxMainFunc changed
    • fs/local: use ebitenutil.OpenFile support wasm
    • update: gop v1.0.12; hajimehoshi/ebiten/v2 v2.2.0; github.com/ajstarks/svgo
    Source code(tar.gz)
    Source code(zip)
  • v0.8.5(Oct 5, 2021)

    new features:

    • new event support: onMoving
    • costumeConfig: support FaceLeft
    • add sprite.SetDying, sprite.Die, sprite.Visible
    • add sprite.ChangeXYpos

    changes:

    • bugfix: Turn(delta) means TurnLeft(delta)
    • remove mutex from Game/Sprite (since we are using single thread model)
    • loadSprite bugfix: init gamer pointer
    • fix: sprite scale
    Source code(tar.gz)
    Source code(zip)
  • v0.8.0(Oct 5, 2021)

    new features:

    • sprite.Animate: support move steps, play sounds and die (i.e. destroy)
    • sprite.Touching support animation
    • audio: mp3 format enhancement (github.com/qiniu/audio v0.2.0)
    • rename OnKey__0 => OnAnyKey (to forbid incorrect use), add OnKey__2
    • support multi call: onClick/onCloned
    • addStageSprites (allow declaring sprite array on stages)
    • specification: can't destroy sprites declared on stages
    • ThreadObj.Stopped: now sprite script is stoppable
    • tutorials: 05-Animation

    changes:

    • github.com/hajimehoshi/ebiten/v2
    • stop "all" => exit
    • spriteDrawInfo.doDrawOn bugfix: allow image size be zero
    Source code(tar.gz)
    Source code(zip)
  • v0.7.0(Oct 4, 2021)

    features:

    • support HideVar/ShowVar
    • support sprite.CostumeSet
    • support sprite.Animate, SetAnimation and load animations from json
    • support sprite.Move and Step
    • test: MonkeyAndCrocodile
    • tutorials: 04-Bullet, 09-AircraftWar

    changes:

    • fix #6
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Sep 28, 2021)

  • v0.5.0(Sep 24, 2021)

    new features:

    • OnCloned/OnKey/OnScene
    • support List
    • support stageMonitor
    • support switch -f (fullscreen)
    • Game.Initialize
    • Value.Int
    • Round
    • abortThread
    • event debug
    • tutorial/02-Dragon
    • tutorial/03-Gobang

    changes:

    • remove sprite.Sink events (old code style)
    • mv tutorial 02-Weather => 01-Weather: remove old style code
    • spx README
    Source code(tar.gz)
    Source code(zip)
Owner
GoPlus
The GoPlus (Go+) Programming Language
GoPlus
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 3 Nov 6, 2022
FlappyCalf - a game powered by Go+ spx game engine

FlappyCalf - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this

GoPlus 3 Nov 6, 2022
MazePlay - a game powered by Go+ spx game engine

MazePlay - a game powered by Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this g

GoPlus 1 Dec 16, 2021
HelloSpx - Hello world of Go+ spx game engine

HelloSpx - Hello world of Go+ spx game engine How to run Download Go+ and build it. See https://github.com/goplus/gop#how-to-build. Download this game

null 1 Nov 27, 2021
HelloWorldForSpx - Hello world of Go+ spx game engine

HelloWorldForSpx - Hello world of Go+ spx game engineHelloWorldForSpx - Hello world of Go+ spx game engine

孙其瑞 3 Nov 22, 2021
The Interpreter of Go+ spx engine

ispx The Interpreter of Go+ spx engine install ispx Go 1.16 go get github.com/vi

GoPlus 2 Jan 26, 2022
Arkanoid game in Go using Ebiten game engine with ECS.

Arkanoid-go Arkanoid game in Go using Ebiten game engine with ECS. You must have Git LFS installed when cloning the repository to download assets. See

null 55 Oct 9, 2022
A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy!

galactic-asteroid-belt Overview A simple game that I created with Ebiten game library as a way to teach myself Go. Enjoy! Run To run, you will need Go

null 0 Dec 2, 2021
RundQuiz-Game - This is a Go exercise that implements and builds a quiz game from a list of math questions in a CSV file.

Go RundQuiz Game Exercise details This exercise is broken into two parts to help simplify the process of explaining it as well as to make it easier to

IkehAkinyemi 0 Jan 5, 2022
Simple 2D game to teach myself various things about game development and ECS, etc

2d-grass-game I really don't know what to name this game. Its a big grass field, and its in 2d so....2D Grass game This is a simple 2D game to teach m

James Wynne III 1 Jan 17, 2022
Engo is an open-source 2D game engine written in Go.

Engo A cross-platform game engine written in Go following an interpretation of the Entity Component System paradigm. Engo is currently compilable for

Engo 1.6k Dec 26, 2022
Go 3D Game Engine

G3N - Go 3D Game Engine G3N (pronounced "gen") is an OpenGL 3D Game Engine written in Go. It can be used to write cross-platform Go applications that

G3N - Go 3D Game Engine Repositories 2.2k Jan 9, 2023
Scalable Distributed Game Server Engine with Hot Swapping in Golang

GoWorld Scalable Distributed Game Server Engine with Hot Reload in Golang Features Architecture Introduction Get GoWorld Manage GoWorld Servers Demos

Nan Lin 2.3k Dec 25, 2022
A pure Go game engine

Oak A pure Go game engine Table of Contents Installation Motivation Features Support Quick Start Implementation and Examples Finished Games Installati

Oakmound Studio 1.3k Jan 8, 2023
Terminal-based game engine for Go, built on top of Termbox

Termloop Termloop is a pure Go game engine for the terminal, built on top of the excellent Termbox. It provides a simple render loop for building game

Joel Auterson 1.3k Dec 29, 2022
A 2D ARPG game engine.

Abyss Engine is an ARPG game engine in the same vein of the 2000's games, and supports playing games similar to Diablo 2. The engine is written in golang and is cross platform. This engine does not ship with game specific files, and will require a game's assets in order to run.

OpenDiablo2 59 Dec 24, 2022
A small fantasy game engine in WASM using GoLang

The GoLang Fantasy Engine (GoLF Engine) is a retro game engine. It draws inspiration from fantasy console projects like pico-8, tic-80, and pyxle. Like those projects it is designed to be a retro-feeling game creation/playing tool. Unlike those projects GoLF is more minimal in scope and only provides an API and a small set of tools to help you create your games. Tools like an image editor and code editor are not built in. Despite this minimalism creating games in GoLF is still easy and should still maintain the retro game feel.

Brandon Atkinson 87 Jul 16, 2022
golang powered game engine

Gobatch Go powered engine that offers features from low level opengl abstraction to UI framework. I created this to separate lot of logic from game am

Jakub Dóka 43 Nov 13, 2022
Go Game Engine using SDL for fun

nMage nMage is a (hopefully!) high performance 3D Game Engine written in Go being developed live, with recordings posted on YouTube. This project is b

Omar Mahdi 57 Nov 30, 2022