add level skeleton
This commit is contained in:
@@ -4,11 +4,12 @@ type User struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
type PlayerState struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
Player Player
|
||||
PlayerState PlayerState
|
||||
User User
|
||||
Level int
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ type Domain struct {
|
||||
Context Context
|
||||
MenuMap konstructor.MenuMap
|
||||
DialogMap konstructor.DialogMap
|
||||
Levels []konstructor.Level
|
||||
}
|
||||
|
||||
func (d *Domain) Init() {
|
||||
d.InitMenu()
|
||||
d.InitDialog()
|
||||
d.InitLevel()
|
||||
}
|
||||
|
||||
41
domain/level.go
Normal file
41
domain/level.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"game/konstructor"
|
||||
)
|
||||
|
||||
func (d *Domain) InitLevel() {
|
||||
d.Levels = []konstructor.Level{
|
||||
{
|
||||
ID: "level_1",
|
||||
Name: "Level I.",
|
||||
Playgrounds: []konstructor.Playground{
|
||||
{
|
||||
Background: "level_1_playground_1.png",
|
||||
Objects: []konstructor.Object{
|
||||
{
|
||||
ID: "test_object",
|
||||
Position: konstructor.Position{
|
||||
X: 10,
|
||||
Y: 10,
|
||||
Z: 0,
|
||||
},
|
||||
Type: konstructor.ObjectType{
|
||||
ID: "test_object_type",
|
||||
RenderOptions: konstructor.RenderOptions{
|
||||
Image: "test_object.png",
|
||||
Width: 30,
|
||||
Height: 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Domain) GetLevel(index int) konstructor.Level {
|
||||
return d.Levels[index]
|
||||
}
|
||||
@@ -29,6 +29,9 @@ func (e *Engine) Update(screen *ebiten.Image) error {
|
||||
if e.ScreenTypeIs("dialog") {
|
||||
e.DialogUpdate()
|
||||
}
|
||||
if e.ScreenTypeIs("playground") {
|
||||
e.PlaygroundUpdate()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -39,6 +42,9 @@ func (e *Engine) Draw(screen *ebiten.Image) {
|
||||
if e.ScreenTypeIs("dialog") {
|
||||
e.DialogDraw(screen)
|
||||
}
|
||||
if e.ScreenTypeIs("playground") {
|
||||
e.PlaygroundDraw(screen)
|
||||
}
|
||||
if e.Controller.Action3Pressed() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -7,4 +7,5 @@ type KContextScreen struct {
|
||||
|
||||
type KContext struct {
|
||||
Screen KContextScreen
|
||||
CurrentLevel int
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ type DomainInterface interface {
|
||||
SetMenu(name string, menu Menu)
|
||||
GetDialog(name string) Dialog
|
||||
SetDialog(name string, menu Dialog)
|
||||
GetLevel(index int) Level
|
||||
}
|
||||
|
||||
type ScreenSettings struct {
|
||||
|
||||
@@ -1,12 +1,77 @@
|
||||
package konstructor
|
||||
|
||||
type PlaygroundObject struct {
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
)
|
||||
|
||||
type Position struct {
|
||||
X int
|
||||
Y int
|
||||
Z int
|
||||
}
|
||||
|
||||
type RenderOptions struct {
|
||||
Image string
|
||||
PosX int
|
||||
PosY int
|
||||
Width int
|
||||
Height int
|
||||
}
|
||||
|
||||
type ObjectType struct {
|
||||
ID string
|
||||
RenderOptions RenderOptions
|
||||
}
|
||||
|
||||
type Object struct {
|
||||
ID string
|
||||
Type ObjectType
|
||||
Position Position
|
||||
}
|
||||
|
||||
type NPCType struct {
|
||||
ID string
|
||||
RenderOptions RenderOptions
|
||||
}
|
||||
|
||||
type NPC struct {
|
||||
ID string
|
||||
Type NPCType
|
||||
Position Position
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
ID string
|
||||
RenderOptions RenderOptions
|
||||
Position Position
|
||||
}
|
||||
|
||||
type ItemType struct {
|
||||
ID string
|
||||
RenderOptions RenderOptions
|
||||
}
|
||||
|
||||
type Item struct {
|
||||
ID string
|
||||
Type ItemType
|
||||
Position Position
|
||||
}
|
||||
|
||||
type Playground struct {
|
||||
Background string
|
||||
Objects []PlaygroundObject
|
||||
Objects []Object
|
||||
NPCs []NPC
|
||||
Items []Item
|
||||
}
|
||||
|
||||
type Level struct {
|
||||
ID string
|
||||
Name string
|
||||
Playgrounds []Playground
|
||||
}
|
||||
|
||||
func (e *Engine) PlaygroundDraw(screen *ebiten.Image) {
|
||||
e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||
}
|
||||
|
||||
func (e *Engine) PlaygroundUpdate() {
|
||||
e.Domain.GetLevel(e.KContext.CurrentLevel)
|
||||
}
|
||||
|
||||
7
main.go
7
main.go
@@ -12,13 +12,14 @@ func main() {
|
||||
k := konstructor.Konstructor{
|
||||
KContext: &konstructor.KContext{
|
||||
Screen: konstructor.KContextScreen{
|
||||
Type: "dialog",
|
||||
Value: "TestDialog",
|
||||
Type: "playground",
|
||||
Value: "",
|
||||
},
|
||||
CurrentLevel: 0,
|
||||
},
|
||||
Domain: &domain.Domain{
|
||||
Context: domain.Context{
|
||||
Player: domain.Player{
|
||||
PlayerState: domain.PlayerState{
|
||||
Name: "Player One",
|
||||
},
|
||||
User: domain.User{
|
||||
|
||||
Reference in New Issue
Block a user