Coder Social home page Coder Social logo

ebitengine-resource's Introduction

I worked on NoVerify static analyzer for PHP and KPHP compiler at vk.com. Before that, I was a part of Intel Go team: I added AVX-512 support and some compiler optimizations there, but most of the time I was tinkering the Go x86-64 assembler.

I try to maintain several[1] good[2] static[3] analyzers[4].
Sometimes I create dev tools like phpgrep (structural PHP code search using AST patterns).

Some facts about me:

  • I do not approve the ways of Russia government (wars, crazy mass propaganda, censorship, ...) ⬜️🟦⬜️
  • I enjoy 3D-printing and drawing
  • I love video games and game development
  • My tech talks and articles can be found at github.com/quasilyte/talks
  • Co-host of the GolangKazan Go community
  • You can call me Alex

ebitengine-resource's People

Contributors

quasilyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

dezren39

ebitengine-resource's Issues

Font Suggestions

Hey! I quite like this library you've put together, but I think the GetFont could be a bit more useful. Right now you have to specify the font size and you cache the face. I want to suggest you cache the font object instead and modify your GetFont to pass in the size and optionally lineHeight.

The reason I am suggesting this is there are cases where for my games, I want to allow the user to specify the font size. If I use this library as is, I would have to define every possible size from the get-go, Additionally if I want x sizes currently, I would be loading the font file x times.

If you want I am more than happy to put together a PR with what I am thinking?

Enable MP3 music type with looping

I spent some time trying to get looping MP3 music going and it was a bit of PITA. Since you support OGG it seems to make sense to support MP3 natively also.

I had to do all this to even get it to load.

// LoopMP3 wraps MP3 stream into an infinite loop.
func LoopMP3(stream io.ReadSeeker) io.ReadSeeker {
	mp3Stream := stream.(*mp3.Stream)
	fmt.Println(mp3Stream.Length())

	return audio.NewInfiniteLoop(mp3Stream, mp3Stream.Length())
}

func LoadMP3(r io.Reader, info resource.AudioInfo) io.ReadSeeker {
	s, _ := mp3.DecodeWithoutResampling(r)

	return s
}

type TEST struct {
	bytes.Reader
}

func (TEST) Close() error {
	return nil
}

func NewGame() *Game {

	// Create a new audio context.
	context := audio.NewContext(44100)

	l := resource.NewLoader(context)
	l.OpenAssetFunc = func(path string) io.ReadCloser {
		v, _ := os.ReadFile(path)
		var result TEST
		result.Reader = *bytes.NewReader(v)
		return &result
	}
	l.CustomAudioLoader = LoadMP3
	l.AudioRegistry.Assign(map[resource.AudioID]resource.AudioInfo{
		audioExample: {Path: "02_seaside_village.mp3", StreamDecorator: LoopMP3},
	})

	l.LoadAudio(audioExample).Player.Play()

	game := &Game{resourceLoader: l}
	return game
}

Provide a default filesystem loader for OpenAssetFunc

It was a bit of a pain trying to figure out how to load an MP3 from the file system. I ended up with something like this
`

type TEST struct {
bytes.Reader
}

func (TEST) Close() error {
return nil
}

l.OpenAssetFunc = func(path string) io.ReadCloser {
	v, _ := os.ReadFile(path)
	var result TEST
	result.Reader = *bytes.NewReader(v)
	return &result
}

`

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.