Jump to content

  • Log In with Google      Sign In   
  • Create Account

Khatharr

Member Since 24 Apr 2010
Offline Last Active Private

#5274564 SFML Cannot get sprite rect to change

Posted by Khatharr on Yesterday, 06:46 PM

You may want to use an enum for directions and make a changeDir() function that will accept a direction as its argument.
class Player {
  //blah blah
  enum Direction : int { DOWN = 0, LEFT, RIGHT, UP };
  Direction facing = DOWN;
  const int TEXTURE_CELL_HEIGHT = 24;

  void changeDir(Direction dir) {
    if(dir != facing) {
      facing = dir;
      sf::IntRect srcRect = playerSprite.getTectureRect();
      srcRect.y = dir * TEXTURE_CELL_HEIGHT;
      playerSprite.setTextureRect(srcRect);
    }
  }

    //...
    if (sf::Keyboard::isKeyPressed(sf::Keyboard::W))
    {
      changeDir(UP);
      player.cPos(0, -10);   
    }
    //...

  //blah blah
}
 
Also, the class is named 'Player', so you don't have to name it's members 'playerThis' and 'playerThat'. You can just use 'this' and 'that', since they're already scoped within Player.


#5274407 Read one text line without limit correctly

Posted by Khatharr on Yesterday, 02:53 AM

http://man7.org/linux/man-pages/man3/getline.3.html

 

This is a nonstandard function, but you didn't say what platform you're on, so...

 

Note the second paragraph in the description.




#5274383 Hi there. Please read. Many thanks.

Posted by Khatharr on 04 February 2016 - 09:13 PM


half a dozen games out over the next 24 months

 

Your future holds difficulty.




#5274168 [Debate] Using namespace should be avoided ?

Posted by Khatharr on 03 February 2016 - 09:29 PM

Never in headers.

 

Prefer scoping it.

 

Pefer:

using std::string;

 

over

 

using namespace std;




#5273784 Where to begin?

Posted by Khatharr on 01 February 2016 - 09:38 PM

Too bad you didn't ask this a few days ago or you could have tried to hook up with a group at Global Game Jam.

 

You may want to google around for jams or similarly structured competitions.

 

I found this in the first few results from "game jam":

http://www.indiegamejams.com/




#5273750 How to implement GLSL marching ant shader

Posted by Khatharr on 01 February 2016 - 05:41 PM

Yes. "Texels" in this case. It's called multi-sampling (though most people asociate that term with antialiasing). There's no trick to it, you just take more than one sample. Be aware that sampling is expensive though.


#5273411 Order of transformation confuse

Posted by Khatharr on 30 January 2016 - 06:20 PM

A) Something is wrong with that mesh.
B) Desk check - do the math on paper to determine your desired matrix, then inspect the matrices being generated.
C) If you want to see which order is giving the correct transform you're going to need another object around the place to compare visually. For a simple box like this you're going to get (should get, anyway) a box from either transform.


#5273352 How to handle Foilage (Tree/Bush) Impact & Motion

Posted by Khatharr on 30 January 2016 - 09:15 AM

Looks nice. You may want to tune the amplitude decay a little more so that it decays faster.

The UDP/TCP thing isn't really a "holy war" issue in this case. For games of this sort with rapid state updates UDP is recommended because lost packets can simply be skipped, rather than waiting for timeout and retransmission. TCP may work over a LAN with limited connections, but beyond that the added latency and packet loss make it untenable. TCP is really tuned for bulk data transmission (file downloads) or transactional exchanges (card games, for example), where latency is less important than reliable delivery and ordering.

Gaffer has a good article about this that explains the reasoning succinctly.

http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/


#5273300 Random Generation Issues

Posted by Khatharr on 29 January 2016 - 08:33 PM

The Generate() function appears to be malformed.

 

Put a breakpoint at the start of it and walk through it with the debugger and look at what it does. If this behavior is intentional then you certainly don't need a loop. I'd also recommend making the randomizer a static member or else placing it elsewhere and passing it in to the function so that you aren't creating a new randomizer object every time the function is called.




#5273271 Warning conversion from size_t to int in x64

Posted by Khatharr on 29 January 2016 - 03:53 PM

It's not really a matter of "yet". It's just not in keeping with the C++ philosophy.




#5273250 Game Command Console

Posted by Khatharr on 29 January 2016 - 01:51 PM

Send messages. You don't need to tightly couple the console, if that's what you're worried about. Just add some message-handling to your systems and make a dispatcher. With that in place the console can just be tied directly to the dispatcher.


#5273247 Online RPG Game Programming

Posted by Khatharr on 29 January 2016 - 01:40 PM

Just to put this on the table, I know we see far too many "How does I MMO" threads, and I understand the chafe that comes from people thinking that game dev is trivial work, but the salt could really stand to be toned down.

A lot.

Especially in FB threads, though I get that this one was moved.

In this case OP didn't really even transgress. There's a stated goal of MMO, but OP demonstrated awareness that there's hard work involved and made a general request for information. While it's certainly worth noting that this is indeed a long haul, it's not fair to OP if we take out our frustration over the other questions. OP is asking where to start learning, not where the 'make MMO' button is on the keyboard.

Just sayin'.


#5272947 How do I create a simple game (2d isometric, turn based) like Pokemon?

Posted by Khatharr on 27 January 2016 - 11:23 PM

Game Maker is free (until you want to advanced publishing features) and simplistic for 2D games. Pokemon isn't isometric, but tile-based. In either case, GM can do tile based (very easily) and isometric (there's a tutorial, I believe).




#5272777 Rendering issue (tearing?)

Posted by Khatharr on 26 January 2016 - 07:11 PM

Vsync causes the renderer to wait for a signal from the display before swapping buffers so that the buffer swaps are synchronized with the monitor refresh.

 

If you're interested in a general purpose image host, I recommend puush, which allows you to upload any image via r-click or to take various forms of screen capture and immediately get a link to the hosted image.




#5272206 sdl 1.2 pacman problems

Posted by Khatharr on 21 January 2016 - 09:08 PM

Perhaps instead of using traditional collision consider using a "rail" system and responding to directional input by setting an "intent" direction?

 

Without having looked at the code I'm guessing that your entity is experiencing a variant of the bullet-through-paper problem, where there's no frame during which he's perfectly aligned with the intersection in order to be able to make his turn.






PARTNERS