Coder Social home page Coder Social logo

Rendering of sprites about engo HOT 9 CLOSED

engoengine avatar engoengine commented on August 19, 2024
Rendering of sprites

from engo.

Comments (9)

matiwinnetou avatar matiwinnetou commented on August 19, 2024

Looking at code more Batch seems to me like Canvas...

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

I have first success to render a sprite.

https://github.com/matiwinnetou/engi/commit/7a3bab3e9adcb294b7b5425fa62c08d818fbca16

I wrote own method:

in assets.go

func (s *Sprite) Render(b *Batch, render *RenderComponent, space *SpaceComponent) {
    b.Draw(s.Region, s.Position.X, s.Position.Y, s.Anchor.X, s.Anchor.Y, s.Scale.X, s.Scale.Y, s.Rotation, s.Color, s.Alpha)
}

probably totally wrong but first success :)

from engo.

paked avatar paked commented on August 19, 2024

@matiwinnetou Hey. I'm not too much of a fan of gitter, I would much prefer IRC. Join me on #engi on freenode if you wish.

from engo.

paked avatar paked commented on August 19, 2024

OK. I've updated the examples to reflect the latest API changes. If you want, you could look through #20. Everything there will compile.

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

Thx, this is appreciated.

I will try to contribute to this project since I have a vision how to improve something and fix problem which I am facing now. Before I do that I will explain you what problem I see at the moment and what is limiting me to write my Galaxian game example.

It seems that the way spritesheets are implemented is that they need to be in a specific order. I can see that some spritesheets not only are not associated with one but multiple sprites but also are not "predictable" and characters and some frames of animation are distributed in somewhat chaotic manner on PNG file. While one could demand to cut such PNG and convert this to a particular order, I think it may be relatively easier to modify code in a way in which Spritesheet could handle also somewhat "chaotic spritesheet pngs". In such case it would be necessary to pass list or array of regions because only manually one would be able at the moment to allocate regions to a spritesheet but at the moment this is not even possible. I would like to develop a prototype.

In addition I think Region type should be either renderable or we should refactor old Sprite type to make it renderable and remove fields, which are no longer needed since they are in SpaceComponent and RenderComponent.

I have some mega proof of concept code running locally in which I can already render successfully Region types using ECS.

I don't get one thing though, how in AnimationComponent it is even possible to value from a sprite sheet will be allocated in constructor? The only constructor or rather factory method which I can see is:

// Create a new pointer to AnimationComponent
func NewAnimationComponent() *AnimationComponent {
    return &AnimationComponent{Animations: make(map[string][]int)}
}

How this can possibly work or is this code in progress?

What do you think in general?

from engo.

paked avatar paked commented on August 19, 2024

@matiwinnetou This all seems like a reasonable idea... But I do not think we should have multiple ways to do the same thing. In all honesty the Sprite struct is legacy and should be removed. And it would make sense for Region's to be Renderable.

I've actually been planning to refractor Animation{Component,System} for a while. So please, go ahead... I totally broke the ECS design while writing that thing.

from engo.

paked avatar paked commented on August 19, 2024

I'd really like to see these changes in a PR (preferably seperately).

from engo.

paked avatar paked commented on August 19, 2024

We can track these problems in #21 and #4

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

Close please.

from engo.

Related Issues (20)

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.