2017-08-13 17:16:12 +02:00
|
|
|
// Copyright 2017 The Ebiten Authors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"image/color"
|
|
|
|
"log"
|
|
|
|
|
2020-10-03 19:35:13 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
|
2022-10-21 08:23:09 +02:00
|
|
|
"github.com/hajimehoshi/ebiten/v2/vector"
|
2017-08-13 17:16:12 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
screenWidth = 640
|
|
|
|
screenHeight = 480
|
|
|
|
)
|
|
|
|
|
2020-05-30 14:14:10 +02:00
|
|
|
type Game struct {
|
|
|
|
count int
|
|
|
|
}
|
2017-08-13 17:16:12 +02:00
|
|
|
|
2020-10-04 10:42:54 +02:00
|
|
|
func (g *Game) Update() error {
|
2020-05-30 14:14:10 +02:00
|
|
|
g.count++
|
|
|
|
g.count %= 240
|
|
|
|
return nil
|
|
|
|
}
|
2017-08-13 17:16:12 +02:00
|
|
|
|
2020-05-30 14:14:10 +02:00
|
|
|
func (g *Game) Draw(screen *ebiten.Image) {
|
2022-10-21 08:23:09 +02:00
|
|
|
cf := float32(g.count)
|
|
|
|
vector.StrokeLine(screen, 100, 100, 300, 100, 1, color.RGBA{0xff, 0xff, 0xff, 0xff})
|
|
|
|
vector.StrokeLine(screen, 50, 150, 50, 350, 1, color.RGBA{0xff, 0xff, 0x00, 0xff})
|
2022-10-21 16:06:52 +02:00
|
|
|
vector.StrokeLine(screen, 50, 100+cf, 200+cf, 250, 4, color.RGBA{0x00, 0xff, 0xff, 0xff})
|
2018-09-15 12:00:57 +02:00
|
|
|
|
2022-10-22 13:29:17 +02:00
|
|
|
vector.DrawFilledRect(screen, 50+cf, 50+cf, 100+cf, 100+cf, color.RGBA{0x80, 0x80, 0x80, 0xc0})
|
2022-10-21 16:06:52 +02:00
|
|
|
vector.StrokeRect(screen, 300-cf, 50, 120, 120, 10+cf/4, color.RGBA{0x00, 0x80, 0x00, 0xff})
|
|
|
|
|
2022-10-22 13:29:17 +02:00
|
|
|
vector.DrawFilledCircle(screen, 400, 400, 100, color.RGBA{0x80, 0x00, 0x80, 0x80})
|
2022-10-21 16:06:52 +02:00
|
|
|
vector.StrokeCircle(screen, 400, 400, 10+cf, 10+cf/2, color.RGBA{0xff, 0x80, 0xff, 0xff})
|
2017-08-13 17:16:12 +02:00
|
|
|
|
2022-07-17 04:25:45 +02:00
|
|
|
ebitenutil.DebugPrint(screen, fmt.Sprintf("TPS: %0.2f", ebiten.ActualTPS()))
|
2020-05-30 14:14:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
|
|
|
|
return screenWidth, screenHeight
|
2017-08-13 17:16:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2020-05-30 14:14:10 +02:00
|
|
|
ebiten.SetWindowSize(screenWidth, screenHeight)
|
2022-08-29 04:16:39 +02:00
|
|
|
ebiten.SetWindowTitle("Shapes (Ebitengine Demo)")
|
2020-05-30 14:14:10 +02:00
|
|
|
if err := ebiten.RunGame(&Game{}); err != nil {
|
2017-08-13 17:16:12 +02:00
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|