Giter Club home page Giter Club logo

hanashi's Introduction

HANASHI

this package provide some limited tools to convey story on ebitengine. As for now it only handle VN-like story telling with some way to handle branching options. Look up on sample directory for some example on how to use this package

Installation

go get github.com/kharism/hanashi

How to use

core.Scene is basically an object we use to store anything to do with the story we want to covey.

scene := core.NewScene()

each scene will have its own set of characters,event, and scene data. We basically put scene in our Update() and Draw(*ebiten.Image) function

func NewScene() *Scene {
	return &Scene{Events: []Event{}, Characters: []*Character{}, SceneData: map[string]any{}}
}

Characters is characters we want to move around in a scene. We need to register each characters first before we can use them to tell a dialogue or monologue.

scene.Characters = []*core.Character{
		core.NewCharacter("sven", "../sample/chr/8009774b-2341-4b31-b63d-e172b525841e.png", &imgPool),
	}

After that we set events as if we write a screenplay

scene.Events = []core.Event{
		core.NewBGChangeEventFromPath("../sample/bg/village.png", core.MoveParam{Sx: 0, Sy: 0, Tx: 0, Ty: -200, Speed: 1}, &imgPool, nil),
		&core.ComplexEvent{Events: []core.Event{
			core.NewCharacterAddEvent("sven", &core.MoveParam{-100, 200, 0, 200, 10}, &core.ScaleParam{0.4, 0.4}),
			// core.NewCharacterAddShaderEvent("sven", &core.ShaderParam{ShaderName: core.DARKER_SHADER}),
			core.NewDialogueEvent("sven", "(What a wonderful scenery)", nil),
		}},
		core.NewDialogueEvent("sven", "(I still have time before dusk to find a way home)", nil),
	}

after that we execute the 1st event

scene.Events[0].Execute(scene)

Set background of the text and set layouter

txtBgImage := ebiten.NewImage(768, 300)
txtBgImage.Fill(color.NRGBA{0, 0, 255, 255})
scene.TxtBg = txtBgImage
scene.SetLayouter(layouter)

after that we set Done Callback

scene.Done = func() {
		os.Exit(0)
	}

The full example of this example is in sample2 directory. Sample directory is for more complex example where we use multiple scene, have scene transition, and dialogue option

hanashi's People

Contributors

kharism avatar

Stargazers

Florian Rohrweck avatar Joel Silva Schutz avatar ganyariya avatar

Watchers

 avatar

hanashi's Issues

Checkout Stagehand 1.1.0

I was very happy to see that you choose to use my library to make your game. It made me feel very proud of myself and very less anxious about spending so much of my free time in it ๐Ÿฅฒ

I saw that you are managing events and using callback, but I'd suggest you check out the new "Scene director" feature, maybe it can simplify some things. Also I think it can be useful for your dialog system to define it like a statemachine, so you can have a more predictable path through the scenes.

Keep on the great job. Good luck!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.