Skip to content

Shaking diagonal movement #2018

Answered by hajimehoshi
alejandro-a asked this question in Q&A
Discussion options

You must be logged in to vote

For example:

//go:build example

package main

import (
	"bytes"
	"image"
	_ "image/png"
	"log"
	"time"

	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/examples/resources/images"
)

const (
	screenWidth  = 640
	screenHeight = 480

	frameOX     = 0
	frameOY     = 32
	frameWidth  = 32
	frameHeight = 32
	frameNum    = 8
)

var (
	runnerImage *ebiten.Image
	op          *ebiten.DrawImageOptions = &ebiten.DrawImageOptions{}
	last        time.Time                = time.Now()
	dt          float64                  = 0
	X           float64                  = 0
	Y           float64                  = 0
)

type Game struct {
	count int
}

func (g *Game) Update() error {
	dt = f…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Sn0rrii
Comment options

@hajimehoshi
Comment options

@hajimehoshi
Comment options

Answer selected by hajimehoshi
@Sn0rrii
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants