Gornova/MarteEngine

Background in Starcleaner

Stef569 opened this issue · 5 comments

The background class is in the package it.marteEngine.game.starcleaner, it is used in

  • it.marteEngine.test.fuzzy
  • it.marteEngine.test.platformer
  • it.marteEngine.test.tank

Dependency between different tests, not good.

The purpose of the Background entity is to render a background nothing else, Is there really a need to create an entity to render the background?

I would like to remove the Background entity and instead do this:

  • backgroundImg = ResourceManager.getImage("background")
  • g.drawImage(backgroundImg,0,0)

thoughts?

There is also a Solid class, that does not do much, I guess if a game uses a solid square it will have a Block class.

Related to issue #50

Maybe we can move Background class to marteEngine, could be useful other than tests, what do you think ?

If we are talking about a static background then I would prefer the 2 lines instead of creating an entity:

Image backgroundImg = ResourceManager.getImage("background")
g.drawImage(backgroundImg,0,0)

If the background can move, fade, rotate... let's create an entity for it:

Entity e = new Entity(0, 0, "Background")
e.depth = -100
world.add(e, World.BELOW)

Extending a class is used to add functionality to it. Not for default values.

A quote from @flowstate:
I don't see why TextEntity and Background are entities. The only thing they have in common with any other Entity is that they need to be rendered.

For things like text messages and background or other static images, I suggest that we make a separate subclass, or perhaps just create an interface for updating and rendering.

The background class we are talking about can be found at: https://github.com/Gornova/MarteEngine/blob/master/test/it/marteEngine/game/starcleaner/Background.java

I know, at MarteEngine start I need some sort of "not so complete" Entity for this things and extending Entity seems to be a good idea.
Can you refactor tests with your implementation of this ?