Slick Forums

Discuss the Slick 2D Library
It is currently Sat May 25, 2013 1:00 pm

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Thu May 10, 2012 9:00 am 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Hi, I'm wondering if it's possible to use the BlockMap and Block classes from Spiegel's tutorials and the addType functionality of Marte Engine for collisions?

The reason I want to do it like this is because, my game is going to have a lot of "oddly shaped" tiles, which will be drawn using TiledMap. An example of this is a Square tile, cut in half Diagonally, like a triangle. Using BlockMap, you use an arraylist of int's, to define the shape of an object, using polygons.

Before using marte engine, i was using a polygon, shaped to the character imagine, to collide with the polygons drawn for the tiles (as shown in Spiegel's Tutorials), but with added gravity and such, it became too unreliable.

I'm guessing there's probably better ways (pixel perfect collision?), but yeh. I'm still learning marte engine, so, it would be a big help if someone could help me :) thanks


Top
 Profile  
 
PostPosted: Sun May 13, 2012 11:59 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
Well, MarteEngine is designed to be simple and fast so maybe is not your choice for do something like this.
You can always add this kind of functionality :D

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Sun May 13, 2012 7:10 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
You mean, add polygon collisions to Marte Engine?

I tried.. i really did... but failed miserably. I then switched it for your Fuzzy code haha. It works brilliantly, except... it eats at the fps like crazy! O_O ..but that might be because i adjusted the code to use smaller tiles (16x16, for smoother platforming action!) and added foregrounds to the maps too... gotta hide the corners of the tiles in my game (design decision lol).


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:53 am 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
take a look here: viewtopic.php?f=10&t=3084

idea: I like adding mask to ME, if you can get a working implimentation, it's ready to be pulled in, what do you think ?

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Mon May 14, 2012 3:45 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Unfortunately, the link to the zip is dead. It seems it wasn't completed either :/


Top
 Profile  
 
PostPosted: Mon May 14, 2012 4:29 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
yes, but you can start from example code instead ? see post

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Mon May 14, 2012 6:48 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Ok, Challenge Accepted!

Obviously, i'll replace the FloatPoint class/methods/whatever with Vector2f (seeing as it does the same thing).

Do i need to add a new method to the Entity class in MarteEngine for the Bitmask?


Top
 Profile  
 
PostPosted: Mon May 14, 2012 8:01 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
yeah cool!

becaus MarteEngine take inspiration from Flashpunk I think you could follow this kind of implementation:
1) collide stuff on Entity remain the same,
2) if a mask is created using a public method on entity, masked based collision is activated
3) mask is created starting from Image

my suggestion is.. keep it simple, make a small prototype, don't waste too time.. game first!

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Mon May 14, 2012 8:55 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Well, i'll see what i can do. Don't hold your breath though. I've only been learning Java for about a month. I'm a quick learner.. but still..

Wouldn't it be best to add a couple of methods to Entity like,

Code:
public void setBitMask (Image image, int imageX, int imageY, int imageWidth, int imageHeight, Image.getColor(0,0)) {
           setBitMask(image, imageX, imageY, imageWidth, imageHeight, image.getColor(0,0));
}


..or something.

That way, instead of "setHitBox(0,0,16,16);", you'd call "setBitMask(image, 0, 0, 16, 16, image.getColor(0,0)); ".

That would potentially create the same thing as a hitbox, but it'd be the bitmask instead.
This is just theory/brainstorming right now, and i honestly have no idea if that would work and what else needs to be done.. but yeh, that seems to fit the "keeping it simple" approach that marteengine uses so well ^_^


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:13 pm 
Offline
Slick Zombie

Joined: Wed Apr 02, 2008 1:32 pm
Posts: 1315
Location: Italy
yeah :D
maybe you should avoid to set width and height because you have Image, at least on basic stuff

_________________
Blog | Last game Gravity Duck tribute | In progress Gravity Duck tribute


Top
 Profile  
 
PostPosted: Mon May 14, 2012 9:37 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
I'm gonna give up for tonight i think lol... head's starting to hurt. I'll look at it again tomorrow.

If you can give me any more hints in the meantime, that'd be great. ;) hehe


Top
 Profile  
 
PostPosted: Tue May 15, 2012 7:24 pm 
Offline

Joined: Mon May 07, 2012 11:36 pm
Posts: 93
Ok, I admit defeat. I don't know enough about what i'm doing to get this to work. Sorry :/


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: SystemNetworks and 2 guests


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