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

Author Topic: Drawing sprites with vectors?  (Read 1063 times)

0 Members and 1 Guest are viewing this topic.

halfmonty

  • Newbie
  • *
  • Posts: 2
    • View Profile
Drawing sprites with vectors?
« on: February 04, 2013, 11:05:20 pm »
To get comfortable with SFML 2.0 and Box2d I'm creating a little Tetris game with physics where the user controls the tetrominoes with their mouse to drag and spin them into place. So far I have the physics under control and working but I am struggling with drawing sprites to all the box2d bodies.

I'm aware of how to create an image and use that image in a sprite and set the location and rotation by getting the values from a box2d body (body is a rect with physics that is invisible) and I can draw a sprite to a body without issue, but what I'm struggling with is the concept or method to create these "on the fly". As per most tetris games the game needs to create new body's and sprites at fixed intervals and I obviously can't pre-define every tetromino that is created.

What is the best method to generate an 'object' with 4 rects and map 4 sprites while keeping track of it well enough to delete specific rects and sprites when there is a "tetris". I assume there are vectors involved but to be honest I've always sucked at using vectors properly. If anyone knows of a 2.0 tutorial that covers dynamic sprite creation or could offer some sage advise I would appreciate it very much. I used most of my brain cells getting SFML and box2d to compile for visual studio 2012 and play nice with each other.

*I have searched for tile map tutorials using sfml sprites because I assumed I'd be able to glom some useful info from it but I've struggle to find anything complete / current and I see a lot of SFML forum responses stating "check 2.0 documentation" which doesn't really provide much in the way of examples or "use the search" which is unhelpful. 9 times out of 10, when I use the search I find posts where the only response is "use the search". Please either offer assistance or delete my topic so it doesn't become search fodder*

halfmonty

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Drawing sprites with vectors?
« Reply #1 on: February 04, 2013, 11:35:47 pm »
Nevermind, I think I got it.

http://en.sfml-dev.org/forums/index.php?topic=7100.0

That has all the pieces, I just need to put it all together for my needs.

 

anything