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 - stoney153

Pages: [1]
1
General / Re: Making SFML smoother and more accurate
« on: June 18, 2013, 04:06:06 pm »
Don't forget to initialize variables and don't put your movement inside the event while loop :)

int Myx;
int Myy;
etc.

You know there's a great little tutorial that might give you a huge insight into this sort of thing. It's outdated and you could code a much cleaner version of it, but try it out:
http://www.dreamincode.net/forums/topic/230524-c-tile-engine-from-scratch-part-1/

It'll give you more of a general insight into the use of sfml for tiled games (but you could modify it to suit your needs) but remember it's outdated. 1.6 instead of 2.0 (I've posted fixed version of some of his work in the comments - for part 2 and 3 I think.

2
General / Re: Making SFML smoother and more accurate
« on: June 17, 2013, 09:28:12 pm »
Oh sorry buddy sure, I've not had enough red bull yet :P

have something like:
Quote
void setpositions(){
   Myx = 100, Myy = 100; //making these global in your header. btw. global stuff - baaaaaaaad idea. but it's an example
        sf::texture txt;
        txt.loadfromfile("w/e");
   sprite.setTexture(texture, true); //assume you've created a sprite in a header or something, otherwise just sf::sprite sprite;
}

void UserInput(){
   if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
      Myy-=4;
   }
   if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)){
      Myx-=4;
   }
   if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)){
      Myy+=4;
   }
   if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)){
      Myx+=4;
   }
}

void drawwindow(){
    window->clear()
    window->draw(sprite)
    window->display();
}

Or something. Try fiddling and get back to me :D ...giggidy? -.-

3
General / Re: Making SFML smoother and more accurate
« on: June 17, 2013, 08:07:38 pm »
Am I thinking about the layout of this the right way?

Quote
playersprite.move ( playersprite.getPosition( window ).x +=0, playersprite.getPosition( window ).y -=10 );

Trying to combine my code with what stoney153 posted, I am just messing around with it right now, codeblocks is complaining about the way I've written it.

You don't need to put:  playersprite.getPosition( window ).x +=0, it's redundant. Just put 0 :P Anywhoo well if you want something simple just make a function for your user input, then add something like: if(sf::keyboard::iskeypressed(sf::keyboard::w)){x-=4} and when drawing your're sprite just use something like: sprite.setposition(x, y); :)

---modify---
P.S you're using 'getPosition' instead of 'setPositon' which would also be an issue. getPosition only finds where the x or y is. setPosition is the modifyer.

4
General / Re: Making SFML smoother and more accurate
« on: June 17, 2013, 05:43:00 pm »
You know the whole 'Blinking across the screen' could just be because you haven't limited the frame rate, like for modern computers a square on the screen isn't exactly demanding, or maybe you're moving it by too many pixels at once (like moving it 50 pixels a time will make it jump like hell). A plethora of answers for such a broad statement :P Also, this may be off topic, but I'd really like to know more about the pizza... ... ...  :o

---You just posted code---
Try using something like myx+=10 (I think sprite.getPosition().x +=10 would also work) for the movement. Or use less pixels because that's a fairly big jump it's making.

5
SFML projects / Re: Game: survival , creative , multiplayer
« on: May 11, 2012, 09:33:45 pm »
It sounds like a nice concept, it sounds similar to Dungeon Defenders (with a bit of Minecraft thrown into it!) :) but I agree with DevilWithin, it'd be nice to see more info!

Pages: [1]
anything