Gornova / MarteEngine

MarteEngine is a Java Engine for videogames
http://randomtower.blogspot.com
Other
74 stars 20 forks source link

Background in Starcleaner #87

Closed Stef569 closed 12 years ago

Stef569 commented 12 years ago

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

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:

thoughts?

Stef569 commented 12 years ago

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.

Stef569 commented 12 years ago

Related to issue #50

Gornova commented 12 years ago

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

Stef569 commented 12 years ago

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

Gornova commented 12 years ago

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 ?