Sign in to follow this  
Experiment-626

Sprite/Entity Screen Wrap

Recommended Posts

Experiment-626    122
Hi all...

When a sprite/entity is going to wrap on the screen, should the engine be the one to detect if it will wrap or should the entity check itself if it will wrap? I suppose this question is asking should I (the sprite/entity) be the one to determine if I can go through the wall or should nature (the engine) determine it. This is more of a philosophical question I guess. lol [img]http://public.gamedev.net/public/style_emoticons/default/blink.gif[/img]

Share this post


Link to post
Share on other sites
ryan20fun    2635
i think it is a little bit about the design of your sprite and engine.

but it would then be the engine that decides what happens IE collisions rendering etc

but it would proberbly be a better idea to have the engine handle as much as you can give it, rather then handing that control to the object.

just my 5 cents.
:) :) :)

Share this post


Link to post
Share on other sites
Experiment-626    122
[quote name='ryan20fun' timestamp='1312821653' post='4846240']
i think it is a little bit about the design of your sprite and engine.

but it would then be the engine that decides what happens IE collisions rendering etc

but it would proberbly be a better idea to have the engine handle as much as you can give it, rather then handing that control to the object.

just my 5 cents.
:) :) :)
[/quote]

I agree but I am having a hard time passing the information to the wrap function to affect the object that needs to wrap.

Share this post


Link to post
Share on other sites
LorenzoGatti    4442
I'll assume that "wrapping" means that when an entity leaves one side of the playfield it enters from the opposite side and it is drawn in both places, like the player's ship in Asteroids.
The main differences between putting this behaviour in the entity or in the engine are:
[list][*] If the entity is in charge, it has to be able to authoritatively tell the engine that it moved to another point. Allowing only the simulation engine to alter entity positions is better for data integrity.[*]If the engine is in charge, it can simply look at entity positions, figure out which ones wrap and where, tell the entity that it moved instantaneously from A to B, and draw the entity (or tell the entity to draw itself to draw itself) both at A and at B.[*]If the entity is in charge, it needs all sorts of vague and complicated information from the engine: is it a wrapping level? Should I wrap or move beyond the screen area? In case I have to wrap, where are my wrap borders?[*]This complicated information is likely to be accessed and processed repeatedly for multiple entities that wrap themselves, while the game engine can figure it out in advance, maintain a list of entities that are meant to wrap, and check them against shared borders.[/list]

Share this post


Link to post
Share on other sites
skuzzbag    120
I think your better off encapsulating any movement behaviour within the object itself if you want to retain Object Oriented design that is easy to follow (remember you'll probably want to revisit this code at some point in the future).. This isn't a bad thing especially when your learning.

Actually sorry I've made an assumption that your using an OO language and you haven't said this!

Still - put it in the sprite code :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this