Coder Social home page Coder Social logo

Sprites about engo HOT 5 CLOSED

matiwinnetou avatar matiwinnetou commented on August 19, 2024
Sprites

from engo.

Comments (5)

paked avatar paked commented on August 19, 2024

Yes we do! Unfortunately, there isn't very much documentation... The component/system are in this file: https://github.com/paked/engi/blob/master/animation.go

If you need any help give me a shout!

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

👍

BTW: it would be nicer if we had a Gitter channel, I am already signed by default to my work slack channel and Gitter is perfect for these things.

I already could comment on some things I encountered while browsing through the code.

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

I am trying the most simple sprite to work, I realized that *Region is renderable but Sprite is not really. Well there is a render method implemented but only a method that takes a *Batch. If I pass this to
engi.NewRenderComponent(

it doesn't work because sprite cannot be rendered...

I modified tilemap example to play with latest API:

package main

import (
    "fmt"
    "github.com/paked/engi"
    "log"
)

var World *GameWorld

type GameWorld struct {
    engi.World
}

func (game *GameWorld) Preload() {
    engi.Files.Add("data/Hero.png")

    log.Println("Preloaded")
}

func (game *GameWorld) Setup() {
    engi.SetBg(0x2d3739)

    game.AddSystem(&engi.RenderSystem{})

    sprites := engi.NewSpritesheet("Hero.png", 15, 15)
    cell := sprites.Cell(1)
    println(fmt.Sprintf("%f", sprites.Height()))
    println(fmt.Sprintf("%f", sprites.Width()))

    gameMap := engi.NewEntity([]string{"RenderSystem"})

    mapRender := engi.NewRenderComponent(cell, engi.Point{1, 1}, "map")
    mapSpace := engi.SpaceComponent{engi.Point{100, 100}, 0, 0}
    gameMap.AddComponent(&mapRender)
    gameMap.AddComponent(&mapSpace)

    game.AddEntity(gameMap)
}

func main() {
    World = &GameWorld{}
    engi.Open("Hello", 1024, 640, false, World)
}

so far no luck to be able to use one tile from the tilemap

from engo.

matiwinnetou avatar matiwinnetou commented on August 19, 2024

there are these methods:

func NewSprite(region *Region, x, y float32) *Sprite {
    return &Sprite{
        Position: &Point{x, y},
        Scale:    &Point{1, 1},
        Anchor:   &Point{0, 0},
        Rotation: 0,
        Color:    0xffffff,
        Alpha:    1,
        Region:   region,
    }
}

func (s *Sprite) Render(batch *Batch) {
    batch.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)
}

but I cannot render a sprite...

from engo.

EtienneBruines avatar EtienneBruines commented on August 19, 2024

@matiwinnetou Can you push the code to (a branch of) your fork? Then I could take a look? (easier when we're using the same code).

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.