2014-12-24 03:04:10 +01:00
|
|
|
// Copyright 2014 Hajime Hoshi
|
|
|
|
//
|
|
|
|
// 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.
|
2014-12-09 15:16:04 +01:00
|
|
|
|
2014-12-08 17:35:35 +01:00
|
|
|
package blocks
|
2013-12-18 10:05:28 +01:00
|
|
|
|
|
|
|
import (
|
2016-02-15 17:13:04 +01:00
|
|
|
"github.com/hajimehoshi/ebiten"
|
2013-12-18 10:05:28 +01:00
|
|
|
)
|
|
|
|
|
2018-01-22 07:12:17 +01:00
|
|
|
const (
|
|
|
|
ScreenWidth = 256
|
|
|
|
ScreenHeight = 240
|
|
|
|
)
|
2013-12-18 19:21:25 +01:00
|
|
|
|
2013-12-18 10:05:28 +01:00
|
|
|
type Game struct {
|
|
|
|
sceneManager *SceneManager
|
2015-01-19 14:21:24 +01:00
|
|
|
input Input
|
2013-12-18 10:05:28 +01:00
|
|
|
}
|
|
|
|
|
2020-04-01 08:57:47 +02:00
|
|
|
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {
|
|
|
|
return ScreenWidth, ScreenHeight
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *Game) Update(*ebiten.Image) error {
|
2018-01-22 07:12:17 +01:00
|
|
|
if g.sceneManager == nil {
|
|
|
|
g.sceneManager = &SceneManager{}
|
|
|
|
g.sceneManager.GoTo(&TitleScene{})
|
2014-05-03 08:25:41 +02:00
|
|
|
}
|
2014-12-06 17:09:59 +01:00
|
|
|
|
2018-01-22 07:12:17 +01:00
|
|
|
g.input.Update()
|
|
|
|
if err := g.sceneManager.Update(&g.input); err != nil {
|
2016-08-02 18:42:46 +02:00
|
|
|
return err
|
|
|
|
}
|
2014-12-06 20:14:35 +01:00
|
|
|
return nil
|
2013-12-18 10:05:28 +01:00
|
|
|
}
|
2020-04-01 08:57:47 +02:00
|
|
|
|
|
|
|
func (g *Game) Draw(screen *ebiten.Image) {
|
|
|
|
g.sceneManager.Draw(screen)
|
|
|
|
}
|