Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Khatharr

Member Since 24 Apr 2010
Offline Last Active Private

#5242551 Making an in game shop?

Posted by Khatharr on 24 July 2015 - 11:46 PM

It sounds like this would be best implemented by simply altering the stats when you make a purchase. The appearance and representation of the "item" can just be treated as another kind of stat, along with things like speed and size, etc.

 

So for a shop you'd want to create an interface that shows the next tier of things along with their prices. When one is selected and confirmed you just modify the relevant state. For example, your game state may have a list of current stats like so:

 

boatSpeed = 3;

bucketSize = 2;

fishingLineStrength = 4;

castingPower = 8;

 

So let's say you want to have the fishing rod as an item that can be upgraded in the shop. You can have an icon that represents the current rod type, and create a set of icons (the actual image files) then give them names like "rod1.png", "rod2.png" and so on. Then add a variable to indicate which rod the player is using:

 

rodIDNum = 1;

 

So when the rod ID is 1 you use the rod1 icon. Then in the shop when the player buys a rod upgrade you just increase the rod ID number and then have a function that loads the new icon and sets the castingPower and fishingLineStrength to the values for a level 2 rod.

 

The same methodology can be used for buckets, boats, etc.

 

Make sense?




#5242270 Build 3D objects in-game?

Posted by Khatharr on 23 July 2015 - 03:54 PM

I don't know if it has a name, but it looks like the game is determining possible locations for whatever item type is selected and then just casting a ray from the cursor and highlighting the indicated position.




#5241644 How to get mouse input from extended frame?

Posted by Khatharr on 20 July 2015 - 08:20 PM

Good to know. Thanks for telling us.

 

Yeah, MSDN doesn't always do a great job of telling you everything you need to know about something unless you really dig around. It's a little better than it used to be, though.




#5241566 How to get mouse input from extended frame?

Posted by Khatharr on 20 July 2015 - 12:22 PM

Almost sounds like your window proc is attached to the wrong window.




#5241559 New Game Programmer!

Posted by Khatharr on 20 July 2015 - 12:11 PM

If this is a deck for drawing from then instead of shuffling the deck you can just make a container of card IDs in any order, then select a random member from that container whenever you want to draw a card.




#5239823 Why Do People Use DirectX?

Posted by Khatharr on 11 July 2015 - 05:04 PM

The first rule of business is that if you see a business doing something odd, it's probably more profitable than the obvious option.
The second rule is that if everyone is doing something and you don't know why, then you better find out before pretending you can undercut them with your obvious answer.

In philosophy this is called the principle of charity.
 

The third rule is that if you swear at people when doing your investigation, as to highlight your frustration regarding the fact that your obvious avenues are apparently not followed, then no one will take you seriously ;)

OP is an information troll. He's doing it right in this case, as he's gotten the information he was after with minimal effort from a group that may have normally been less inclined to provide in-depth responses.

See http://www.crazyboy.com/fravia/searchlores.org/trolls.htm.




#5239679 Best way to store a stage for a platformer?

Posted by Khatharr on 10 July 2015 - 11:09 PM

I would say that unless you are using some really large images or having something extreme going on, in general brute force rendering, less images is faster to draw.

 

It's really texture binding that could kill it. If you use sheets instead of individual tiles then you can draw a whole layer from a single sheet and take advantage of the parallel nature of the GPU. Binding a couple sheets for the whole scene should be a lot gentler than binding a megalithic image, although modern cards can handle pretty large textures. Drawing the whole BG with one image you have a lot fewer vertices and a less frustum clipping to handle, but you're also dumping all the work on the rasterizer in one (or two) big chunk(s). I'm not sure how a modern GPU would like that compared to a handful of 64x64 tiles, for instance. It's something worth doing some bench testing on.

 

Some hardware really dislikes drawing overly large primitives. I remember on PSP it was faster to draw a fullscreen image in 4 or 5 vertical strips than it was to draw one giant quad because of the limitations of the rasterizer (I think... That was a few years ago.). There was some stride limit that it liked that I can't remember now, and if you stayed inside that limit you get a marked increase in render performance.

 




#5239575 Best way to store a stage for a platformer?

Posted by Khatharr on 10 July 2015 - 01:15 PM

In my current game, coded in Java, I store it in a 2D byte array(width, height). Each element is the size of a pixel.
 
When the stage gets large, the amount of ram used for it as high as 150 mb.

 
For a moment I thought you were saying that your maps were 157 million tiles in size. I was going to say, "Make smaller maps." smile.png
 

It is technically slower to draw all the different tiles instead of a couple huge images(in modern rendering engines anyway), but it is far from deal breaking.


I think that you'll find that the difference is negligible if you're using a proper tilesheet(s) and a thoughtful rendering process. It's even conceivable that tiles will outperform.


#5239570 How to "smooth" a path

Posted by Khatharr on 10 July 2015 - 12:59 PM

If you're just concerned about the appearance of the motion then you could just have the agent use steering behaviors to move between nodes and avoid brushing against corners.




#5238590 Android Multiplayer without Google+

Posted by Khatharr on 06 July 2015 - 05:23 AM

 

angry.png  This is his first post, and it's in the noob section. At least speak to him.

 

Hello, Benateg. Welcome to GDN. I don't have much truck with networking SDKs myself, but there are some more experienced people around the place. I'm sure a few of them can give you some suggestions about where to get started in terms of packaged solutions. You may also want to peek at the networking and multiplayer forums and see if there's any discussion of such packages going on in there.

 

Good luck!




#5237167 Can't convert array of strings to char array

Posted by Khatharr on 27 June 2015 - 04:48 PM

Oh, and apparently we all forgot to mention it, but you don't have to add the trailing zero to string literals. If you use "double quotes" then it appends a trailing zero automatically. If you use 'single quotes' then it doesn't. Also, I suspect part of the bug you were running into had to do with trying to fit things like "Open\0" (a total of 6 characters) into an array of 4 chars.




#5237020 Can't convert array of strings to char array

Posted by Khatharr on 26 June 2015 - 08:05 PM

Generally you don't want to mix STL stuff with stdlib stuff. In this case there's really no reason to do what you're trying to do. If you want to get a C-style string from a std::string, you just use the .c_str() member function. If you want to stream a std::string to std::cout, you just do it. There's no conversion necessary.

 

Concerning the passing of static arrays into functions... Which then have incorrect methods attempting to determine the length of the array...

 

Firstly, when passing a complex or potentially large object into a function, pass it by reference instead of by value:

 

void doStuff(std::string& myString) { /*stuff*/ }

 

If you want to prevent it from being altered within the function then make it a const reference:

 

void doStuff(const std::string& myString) { /*stuff*/ }

 

When you pass by value, the thing you pass gets copied into the function. When you pass by reference, only the refrence gets passed in, which is much smaller, and doesn't invoke any copy behaviors.

 

Secondly, if you want to pass around arrays of variable length, then use std::vector.

 

void doStuff(const std::vector<std::string>& myVectorOfStrings) {
    for(auto& str : myVectorOfStrings) { //std::vector supports the new for-each loop type
        std::cout << str << "\n";
    }
 
    for(int i = 0; i < myVectorOfStrings.size(); i++) { //it's also aware of its own size (in terms of member count)
        std::cout << myVectorOfStrings[i] << "\n"; //and can be indexed like an array
    }
}

 

Keep at it. You'll get there.




#5230510 A whole lot of constants.... good or terrible? :/ (c++)

Posted by Khatharr on 22 May 2015 - 06:14 PM

Note that if you declare an enum or a static member within the public section of a class, you can access it externally:

class Foo {
public:
  enum Bar {
    BAZ = 12
  };
};

void someFunctionElsewhere() {
  Foo::Bar temp;
  temp = Foo::BAZ;
}

This can be useful if you want to have a public member function that takes an enum argument:

class Text {
public:
  enum HorizontalAlignment {
    HALIGN_LEFT,
    HALIGN_CENTER,
    HALIGN_RIGHT
  };
  
  void setHorizonalAlign(HorizontalAlignment hAlign);
};

void someFunctionElsewhere() {
  Text obj;
  obj.setHorizonalAlign(Text::HALIGN_CENTER);
}



#5228843 (Best Practice) Multithreading instantiation

Posted by Khatharr on 13 May 2015 - 02:32 PM

You could set up a messaging system and work with interfaces, or you could have another think about threading something that sounds like it doesn't want to be threaded.




#5228842 Make the camera follow the sprite

Posted by Khatharr on 13 May 2015 - 02:28 PM

Looking at that video, it keeps the line in screen space and simply converts the coords to world space while the line itself remains locked to the camera position.

 

If you have some differences in your implementation that make it more of a problem then just pin the camera while the mouse button is pressed.






PARTNERS