gameraycast

package
v0.0.0-...-ce97658 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

README

NOTE: This is currently a modified fork of https://github.com/samuel-pratt/raycaster, which will be reworked quite substantially to combine features of various raycasting implementations using ebiten and sdl.

This is an excellent collection of tutorials on raycasting:

Further, excellent resources on raycasting:

The ultimate goal is to create a basic dungeon crawler for the various dungeon and tile map generators that accumulate in this repository.

alt text

Textures

Some textures are from Wolfenstein 3D, which is a public domain game.

alt text

TODO

  • Basic raycasting, movement, rendering
  • Add different wall types and colors
  • Custom FOV and ray resolution
  • Add textures
    • Basic, single texture
    • Multiple textures
  • Add minimap
  • Add custom maps
    • Remove hardcoded map
    • Add example dungeon map import
  • Add sprites
  • Add enemies
  • Add map marker for player start
  • Add doors
    • Add door texture
    • Add door interaction
    • Allow doors to close again instead of removing them
    • Add door opening / closing animation
  • Add stairs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dist

func Dist(x1, y1, x2, y2 float64) float64

Types

type BitTexture

type BitTexture struct {
	W      int
	H      int
	Bitmap [][]byte
	Colors []color.RGBA
}

BitTexture is a texture that is defined by a bitmap and a color palette.

func (*BitTexture) At

func (t *BitTexture) At(x, y int) color.Color

At returns the color at the given coordinates.

func (*BitTexture) Height

func (t *BitTexture) Height() int

Height returns the height of the texture.

func (*BitTexture) Width

func (t *BitTexture) Width() int

Width returns the width of the texture.

type Game

type Game struct {
	Scale int // Map Scale (how many pixels per tile)

	*Map // Map
	// contains filtered or unexported fields
}

Game represents the game.

func NewGame

func NewGame(m *Map) *Game

NewGame creates a new Game

func (*Game) CastRays

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

CastRays casts rays from the player to the map.

func (*Game) Draw

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

Draw draws the game screen.

func (*Game) DrawMap

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

func (*Game) KeyboardHandler

func (g *Game) KeyboardHandler()

func (*Game) Layout

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

Layout returns the screen size.

func (*Game) Run

func (g *Game) Run()

Run starts the game.

func (*Game) Update

func (g *Game) Update() error

Update updates the game state (keyboard input).

type ImgTexture

type ImgTexture struct {
	// contains filtered or unexported fields
}

ImgTexture is a texture that is defined by an image.

func NewImgTexture

func NewImgTexture(img image.Image) *ImgTexture

NewImgTexture returns a new texture that is defined by an image.

func (*ImgTexture) At

func (t *ImgTexture) At(x, y int) color.Color

At returns the color at the given coordinates.

func (*ImgTexture) Height

func (t *ImgTexture) Height() int

Height returns the height of the texture.

func (*ImgTexture) Width

func (t *ImgTexture) Width() int

Width returns the width of the texture.

type Map

type Map struct {
	X     int   // Map Width
	Y     int   // Map Height
	Array []int // Map Array
}

Map represents the map.

func NewMap

func NewMap() *Map

NewMap creates a new Map.

type TexInterface

type TexInterface interface {
	Width() int              // Width returns the width of the texture.
	Height() int             // Height returns the height of the texture.
	At(x, y int) color.Color // At returns the color at the given coordinates.
}

TexInterface is an interface for textures.

func NewImgTextureFromBytes

func NewImgTextureFromBytes(p []byte) (TexInterface, error)

NewImgTextureFromBytes returns a new texture that is defined by an image.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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