package main
import (
"log"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/v2"
"fmt"
)
const (
screenWidth = 640
screenHeight = 480
ballSpeed = 3
paddleSpeed = 6
)
type Object struct {
X, Y, W, H int
}
type Paddle struct {
Object
}
type Ball struct {
Object
dxdt int
dydt int
}
type Game struct {
paddle Paddle
ball Ball
score int
highScore int
}
func main() {
ebiten.SetWindowTitle("Pong using ebitengine.")
ebiten.SetWindowSize(screenWidth,screenHeight)
g := &Game{}
err := ebiten.RunGame(g)
if err != nil{
log.Fatal(err)
}
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
return screenWidth, screenHeight
}
func (g *Game) Draw(screen *ebiten.Image){}
func(g*Game) Update() error{
return nil
}
}
I’m trying to learn to make a small game project in Go using ebitengine.
and the layout funtion block the following error code is displayed: unexpected int in argument list; possibly missing comma or )
and “non-declaration statement outside function body” is displayed.
I was expecting to see a blank game screen.
New contributor
Fluorite is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.