Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A simple console emulator for ascii games written in go

License

NotificationsYou must be signed in to change notification settings

BigJk/ramen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocumentationGo Report CardHex.pm

ramen is a simple console emulator written in go that can be used to create various ascii / text (roguelike) games. It's based on the greatebiten library and inspired by libraries likelibtcod.

Warning: API and features are not fixed yet. Bugs will happen!


Features

  • PNG Fonts with more than 256 chars possible
  • Fonts can contain chars and colored tiles
  • Create sub-consoles to organize rendering
  • Component based ui system
  • Inlined color definitions in strings
  • Pre-build components ready to use
    • TextBox
    • Button
  • REXPaint file parsing
  • Everythingebiten can do
    • Input: Mouse, Keyboard, Gamepads, Touches
    • Audio: MP3, Ogg/Vorbis, WAV, PCM
    • ...

Get Started

go get github.com/BigJk/ramen/...

Transformer

In ramen you change the content of the console by applying transformations to cells. Examples would be:

// set one cell at position 10,15 to a green @:con.Transform(10,15,t.CharByte('@'),t.Foreground(concolor.RGB(0,255,0)))// change the background of the area 0,0 with the width and height of 25,25:con.TransformArea(0,0,25,25,t.Background(concolor.RGBA(255,255,255,20)))// change the background of all the cells:con.TransformAll(t.Background(concolor.RGBA(255,255,255,10)))

All transformer functions accept objects that implement thet.Transformer interface, so it's also possible to create transformers with custom behaviour by implementing that interface.

Inlined Color Definitions

There are also convenient string printing functions. Theconsole.Print function supports parsing of inlined color definitions that can change the forground and background color of parts of the string.

[[f:#ff0000]]red foreground\n[[f:#ffffff|b:#000000]]white foreground and black background\n[[b:#00ff00]]green background

Example

package mainimport ("fmt""github.com/BigJk/ramen/concolor""github.com/BigJk/ramen/console""github.com/BigJk/ramen/font""github.com/BigJk/ramen/t""github.com/hajimehoshi/ebiten/v2")funcmain() {// create a 50x30 cells console with the title 'ramen example'con,err:=console.New(50,30,font.DefaultFont,"ramen example")iferr!=nil {panic(err)  }// set a tick hook. This function will be executed// each tick (60 ticks per second by default) even// when the fps is lower than 60fps. This is a good// place for your game logic.//// The timeDelta parameter is the elapsed time in seconds// since the last tick.con.SetTickHook(func(timeElapsedfloat64)error {// your game logicreturnnil  })// set a pre-render hook. This function will be executed// each frame before the drawing happens. This is a good// place to draw onto the console, because it only executes// if a draw is really about to happen.//// The timeDelta parameter is the elapsed time in seconds// since the last frame.con.SetPreRenderHook(func(screen*ebiten.Image,timeDeltafloat64)error {con.ClearAll()// clear consolecon.TransformAll(t.Background(concolor.RGB(50,50,50)))// set the backgroundcon.Print(2,2,"Hello!\nTEST\n Line 3",t.Foreground(concolor.RGB(0,255,0)),t.Background(concolor.RGB(255,0,0)))con.Print(2,7,fmt.Sprintf("TPS: %0.2f\nFPS: %0.2f\nElapsed: %0.4f",ebiten.CurrentFPS(),ebiten.CurrentFPS(),timeDelta))returnnil  })// start the console with a scaling of 1con.Start(1)}

Screenshots

About

A simple console emulator for ascii games written in go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp