game

package
v0.0.0-...-b8b9dc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2020 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package game Copyright (C) 2020 Loïg Jezequel

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	InfoBlock  = "A game developped in 48h\n    by Loig Jezequel\n   for Ludum Dare 46!\n(see  https://ldjam.com)"
	InfoBlock2 = "All images and sound are"
	InfoBlock3 = "  Code source under GPL-3.0\n         available at\n https://github.com/loig/ld46"
)

Menus animation management

View Source
const (
	Title        = "ld46"
	ScreenWidth  = 256
	ScreenHeight = 256
)

Constants defining the basic parameters of the game

Variables

View Source
var ErrEndGame = errors.New("End")

ErrEndGame is raised at the end of a game

Functions

This section is empty.

Types

type Focus

type Focus int

Focus defines the focused item of the menu

const (
	Play Focus = iota
	Info
	Quit
	EndMenu
)

Possible Focus values

type Game

type Game struct {
	GameState                  State
	StateAfterMenu             State
	PlayerAnimationStep        int
	PlayerAnimationFrame       int
	FlowerAnimationStep        int
	FlowerAnimationFrame       int
	EndLevelStep               int
	EndLevelAnimationStep      int
	EndLevelAnimationFrame     int
	EndGameAnimationStep       int
	EndGameAnimationFrame      int
	FallingTilesAnimationStep  map[level.TilePosition]int
	FallingTilesAnimationFrame map[level.TilePosition]int
	PlayerState                PState
	PlayerX                    int
	PlayerY                    int
	FlowerState                level.Object
	ResetLevel                 level.Level
	CurrentLevel               level.Level
	LevelNumber                int
	TutoNumber                 int
	Tiles                      *ebiten.Image
	MenuFocus                  Focus
	DisplayFont                font.Face
	InfoFont                   font.Face
	Scores                     [5]int
	TotalScores                [5]int
	AudioContext               *audio.Context
	SoundPlayers               [numSound]*audio.Player
	MusicPlayer                *audio.Player
}

Game defines the general game structure

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw for ensuring that Game implements the ebiten.Game interface

func (*Game) InitGame

func (g *Game) InitGame()

InitGame performs all necessary stuff before starting a game, except for media loading

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeigth int) (screenWidth, screenHeight int)

Layout for ensuring that Game implements the ebiten.Game interface

func (*Game) PlaySound

func (g *Game) PlaySound(soundName SoundName)

PlaySound plays one sound effect

func (*Game) ResetAnimation

func (g *Game) ResetAnimation()

ResetAnimation restarts all the animations

func (*Game) Update

func (g *Game) Update(screen *ebiten.Image) error

Update for ensuring that Game implements the ebiten.Game interface

func (*Game) UpdateAnimation

func (g *Game) UpdateAnimation()

UpdateAnimation determines the step of the animation of each element of the game

func (*Game) UpdateEndGameAnimation

func (g *Game) UpdateEndGameAnimation()

UpdateEndGameAnimation determines the step of the final animation

func (*Game) UpdateEndLevelAnimation

func (g *Game) UpdateEndLevelAnimation()

UpdateEndLevelAnimation determines the step of the animation transition between levels

func (*Game) UpdateFallingTilesAnimation

func (g *Game) UpdateFallingTilesAnimation()

UpdateFallingTilesAnimation determines the step of the animation of every currently falling tile

func (*Game) UpdateFlowerAnimation

func (g *Game) UpdateFlowerAnimation()

UpdateFlowerAnimation determines the step of the animation of the player

func (*Game) UpdatePlayerAnimation

func (g *Game) UpdatePlayerAnimation()

UpdatePlayerAnimation determines the step of the animation of the player

type PState

type PState int

PState defines a possible state of the player

const (
	Dead PState = iota
	HoldingNothing
	HoldingWater
)

Possible PState values

type SoundName

type SoundName int

SoundName give names to sounds

const (
	PlayerFallSound SoundName = iota
	TileFallSound
	WaterFlowerSound
	TakeWaterSound
	PlayerMoveSound
	VictorySound
	ScoreDisplaySound
	PlayerDashSound
	LevelBeginSound
	ResetSound
	MenuMoveSound
	MenuConfirmSound
)

These constants register the different sounds that can be played

type State

type State int

State defines a possible state of the game

const (
	BeginMenu State = iota
	InTuto
	InLevel
	LevelFinished
	GameFinished
	InfoPage
)

Possible State values

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL