[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Slick Forums • View topic - Visualising Entity and Component in a jigsaw puzzle game

Slick Forums

Discuss the Slick 2D Library
It is currently Fri Feb 28, 2020 2:55 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Sun Jan 27, 2013 9:07 pm 
Offline

Joined: Sun Jan 27, 2013 8:56 pm
Posts: 7
hi!
I had been working on a jigsaw game. And have uptill now used MVC framework, for all it's functionalities. I recently, went through PBE ( Push Button Engine) which is entity-component based model, and was intrigued to know, if a game like jigsaw a good candidate for entity-component based model. Unfortunately it seems like forums for Push Button no longer exists. However, when i googled i found Artemis something similar. So what parts can i categorize as a "System" , "Entity" and "Components" in a jigsaw type game. Thanks.


Top
 Profile  
 
PostPosted: Mon Jan 28, 2013 7:03 am 
Offline

Joined: Mon Jan 21, 2013 8:52 pm
Posts: 7
There's probably a ton of ways to do this, but this is what I would do:

First, obviously, the jigsaw pieces are your entities. The best approach to designing a game for ECS is to think about what aspects your Entities might have in the world. In thise case, they should all have some sort of position on the screen, they should have a visual representation, they are moveable with user control, and they all have a spot on the board that represents their final resting place. I would set up components like these:

Position - For current position.
RenderComponent - For visual representation
Shape - shape of the piece for figuring out mouse overlap, etc
UserControl - Everything needed for user control
Goal - positioning threshold for snapping the jigsaw piece to it's right spot.

Think of your systems as what defines the actions the entities can perform. For instance, we definitely want our pieces to display to the screen. We probably want them to move when the mouse drags them. We might want them to snap into place when they are dropped near their goal point. I would go for something like this:

RenderSystem : Draws Entities with render components at position
UserControlSystem : Process user control (On mouse down select piece, on mouse move, move selected piece, mouse down drop piece, etc)
GoalSystem : lock pieces in place if they are close enough to their goal ( ex. If UserControlComponent.isNotBeingHeld && Position.closeEnoughTo(Goal.goalPosition) Lock piece into place, etc )

I don't want to get too detailed, (Wheres the fun in that, right?) There might be other unforseen hurdles to get over, but this should be enough to point you in the right direction. I would venture a guess that generating the puzzle pieces and constructing the game objects in a sensible way would be the most difficult part to accomplish.

All in all, approach those design questions with "What do I want my Entities to do?" and "What characteristics do they need to have to do that?" The answer to the first question is your Systems, and the answer to the second question are your Components.

Hope this helps! :D


Top
 Profile  
 
PostPosted: Mon Jan 28, 2013 8:03 am 
Offline

Joined: Sun Jan 27, 2013 8:56 pm
Posts: 7


Top
 Profile  
 
PostPosted: Mon Jan 28, 2013 11:14 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1340
Location: Italy
this can help: http://gamadu.com/artemis/manual.html#Introduction

_________________
| Last game


Top
 Profile  
 
PostPosted: Mon Jan 28, 2013 11:41 am 
Offline

Joined: Sun Jan 27, 2013 8:56 pm
Posts: 7
Thanks for the link. I had missed this page.


Top
 Profile  
 
PostPosted: Sun Feb 03, 2013 7:33 am 
Offline

Joined: Sun Jan 27, 2013 8:56 pm
Posts: 7


Top
 Profile  
 
PostPosted: Thu Feb 07, 2013 1:22 pm 
Offline

Joined: Thu Oct 25, 2012 5:29 pm
Posts: 31
@comet

Any quick thoughts on how you would implement the drag and drop / snap into place action for those pieces? I have a project and code which does something similar, but I'd love to see someone else's idea on how it could be done. I imagine mine can't be all that neat or clean as it should.


Top
 Profile  
 
PostPosted: Thu Feb 07, 2013 1:27 pm 
Offline

Joined: Thu Oct 25, 2012 5:29 pm
Posts: 31
Oh,

And because I'm doing something similar, if you figure out how to always have the jigsaw puzzle piece you are currently moving around render on top of everything else, let me know.


Top
 Profile  
 
PostPosted: Fri Feb 08, 2013 10:36 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1340
Location: Italy
@bagpipes100: it's up to you. Your rendering system render images in order you want, so you could place selected piece as last rendered, maybe using a z-level rendering system? So for example: piece1,2,3 have z-level 0 and selected piece 4 z-level1

_________________
| Last game


Top
 Profile  
 
PostPosted: Fri Feb 08, 2013 3:13 pm 
Offline

Joined: Thu Oct 25, 2012 5:29 pm
Posts: 31
Artemis though decides the order in which to process entities for rendering. Or is there a way to change this?


Top
 Profile  
 
PostPosted: Fri Feb 08, 2013 3:22 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1340
Location: Italy
I mean: you write your own rendering system so you can render stuff in your way, no ?

_________________
| Last game


Top
 Profile  
 
PostPosted: Mon Mar 11, 2013 4:43 am 
Offline

Joined: Mon Jan 21, 2013 8:52 pm
Posts: 7


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group