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

Author Topic: Tetris Clone - Yes I am a beginner so what wana fight about it?  (Read 1861 times)

0 Members and 1 Guest are viewing this topic.

aNewHobby

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • Live 4 Ever Or Die Trying


I have been trying to build a SFML version of Tetris using c++ as a project to help my learning process. Everyone says that it is a great starting point.

Anyway, I have kind of got a semi working prototype using arrays, one cell for each block, a number of blocks for each peace, a simple test to see if a cell is filled or not for collision. Then I was looking through the forum and I saw this post

http://en.sfml-dev.org/forums/index.php?topic=6992.msg46217#msg46217
Just a suggestion, but if you used sf::Rect's instead of vectors, you could reduce your code down to like 2 lines.


if(ballRect.Intersects(paddle1Rect) return PADDLE1HIT;
if(ballRect.Intersects(paddle2Rect) return PADDLE2HIT;

doe this mean the primitive squares and stuff have their own collision detection functions built in? Would this be usabe.. say using them and overlaying fancy sprites ontop or something?
Twitter: @Jyinkies
My Own Little Spot on the Net: - Live4everOrDieTrying.info (Blog)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Tetris Clone - Yes I am a beginner so what wana fight about it?
« Reply #1 on: May 07, 2012, 05:39:21 pm »
SFML doesn't have real collision detection mechanisms, it can just find out if and how rectangles overlap. For more advanced tasks, you could look at Boost.Geometry or a full physics library like Box2D, although I doubt it's appropriate for a Tetris.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: