Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Skuller74

Pages: [1]
1
General / Collision Detection in "more advanced" 2D Scenario
« on: March 10, 2012, 09:07:59 am »
Okay awesome, thanks for the quick reply. I have one more quick question in regards to this.

I feel like this is the right way but I'd like to double check. Should I store all of the sprites using a vector, and then use a for loop to cycle through each one, checking for collision each iteration? I've never used a vector, but I know the general idea of how to implement one.

2
General / Collision Detection in "more advanced" 2D Scenario
« on: March 10, 2012, 08:02:32 am »
So far I have coded a simple Pong clone, and a Tetris clone. Collision detection was very simple in these. Pong: If ball has negative velocity, check collision on left paddle, if ball has positive velocity, check for collision on right paddle. With tetris, I set the board up as an array of 0s (empty), 1s (occupied), and 2s (board boundary), checked board space in the direction in which the piece was about to move, and did stuff based on the result. This may not have been the best way but I wanted to try something different.

Now I am moving on to Sprite-based bounding-box collision detection. I haven't actually started the project yet; however, I am planning for a Pac-Man clone or Pac-Man-esque game if I decide to change it up.

I plan on displaying the board as a series of sprites assigned to different numerical values and load it from an arbitrary file, say "maze1.map", which contains a 2D array of the previously stated numbers based on the shape of the maze piece (vertical, horizontal, corners, and end pieces). I'd like to eventually extend this to a map editor, but may save this for a future project.

:arrow:!! START HERE IF YOU DON'T CARE ABOUT THE OTHER BULLSHIT !! :: Anyways, I'm wondering how to process collision detection with so many "collidable" sprites on the board at one time (on a game such as pacman, using collidable sprites for maze pieces and precise bounding-box collision). Do I check EVERY sprite on the board for collision every time the frame updates? Or do I divide the board into quadrants, change which quadrant I'm testing based on the area of the character (and ghosts), and only check that quadrant/subquadrants?

I don't need code help or anything with this, just theory on how to handle collision detection.

Thanks :D

3
General / Tetris Problem
« on: February 21, 2012, 11:11:50 am »
Hi! I'm new here to SFML. Just started using it 3 days ago or so. Today, I completed a Pong clone and now I'm working on a Tetris clone.

I'm looking for a more elegant solution for Tetroid creation/manipulation. I could divide each tetroid into it's own image and load them from there; however I would like to use as few images as possible. Currently, other than the UI Overlay I'm using, I only load 1 image, that being a single block.

Code: [Select]
void Tetroid::build(sf::Image &blockImg, tetType shape)
{
if (shape == Z)
{
focus.newBlock(blockImg, COLOR_Z);
focus.setDefaultPos();

block2.newBlock(blockImg, COLOR_Z);
block2.setDefaultPos();
block2.Up();

block3.newBlock(blockImg, COLOR_Z);
block3.setDefaultPos();
block3.Up(); block3.Left();

block4.newBlock(blockImg, COLOR_Z);
block4.setDefaultPos();
block4.Right();
} ...

}


I'm creating a Tetroid object out of 4 Block objects(which contain the block's sprite), setting one of those block objects as a focus and positioning the others around the focus. I do this for each shape.

As for movement...

Code: [Select]
void Tetroid::Left()
{
focus.Left();
block2.Left();
block3.Left();
block4.Left();
}


I'm just looking for suggestions on how to better go about creating/manipulating these objects. Would it be better to load 7 separate images and create sprites from each? Or make a sprite sheet containing each Tetroid and its respective rotations and SetSubRect it?

Like I said, I'm new to SFML, the Pong clone was the first multimedia based game I've ever created.

Any help would be greatly appreciated  :D

edit: A little more information...

Obviously this will be addressing rotation as well. With my current setup, I will have to store the state of the active Tetroid as one of four rotational states,  then SetPosition of each block around the focus for the rotation. This I could see as being advantageous as a solution for a rotation near the inactive blocks at the bottom of the field, to avoid clipping and detecting a collision, so a shape can be quick-rotated into a snug spot.

Anyways bed for me..zzzz

Pages: [1]