Tag Info

New answers tagged

0

I highly recommend you look into spritesheets, for memory efficiency/performance. There are a couple of tools out there to help you convert your collection of images into a spritesheet, such as this open source one, or my Gimp plugin for it. A quick google found me this sdl2 tutorial on spritesheets.


1

For loading the images, you could do: std::vector<imagebatch> fotos; std::vector<SDL_Texture*> healerTexture; // Parts of filename string that occur multiple times. char* filenameBase = "DData/towners/healer/healer/Healer"; char* fileExt = ".png"; // This is 15 because of the number of images there are. for (int i = 0; i < 15; ++i) { ...


1

After your glClear call you can render a full-screen quad with your texture (loaded like you would any other). You may want to disable writing to the depth buffer to avoid odd rendering issues.


0

You already got your position and your rotation, just take those values from the spaceship and create a bullet from them. If you dont want them to start in the middle of your spaceship, move them a few times in velocitys direction.


5

A singleton works. A global works. I'll stand by that statement. I don't think they're the best solution for this particular case, though. Yes, you can put all your GameObject instances into a World of some kind. The World then likely needs to be managed by an object if you plan to have more than one of them, e.g. some kind of WorldManager. This manager ...


0

FBX supports a whole range of texture properties per surface material: diffuse, specular, etc.. The property names are stored in static char* fields in SDK classs FbxSurfaceMaterial. You can get a pointer to such a material by iterating across all materials of an FbxNode using functions GetMaterialCount() and GetMaterial(index). To load a texture, you first ...


3

To find the normal, you can use the cross product of three of the points in the polygon. Create two vectors from those three points and find the cross product of those. To find the intersection of the ray with the polygon, you will first need to ensure it intersects with the plane of the polygon. To do this, you will need to do some algebraic manipulation ...


0

If the DLL is not a .Net assembly (i.e. cannot be loaded in the References folder) put it in the root folder (not the assets)


2

It's pretty straightforward, if not entirely well documented. Reading the source (not sure if the released version differs significantly) tells me that you must export an environment variable SDL_DYNAMIC_API with the name of the .so you want to load. That .so must contain a symbol SDL_DYNAPI_entry with signature: Sint32(SDLCALL*)(Uint32 apiver, void *table, ...


0

You just need a simple DFS algorithm ! Here you go: Run DFS every time player go on a empty block. Your DFS should navigate empty block until reach a filled (blue) block. this is stop condition of your DFS. Then in DFS, check if all DFS-branches stuck to a filled block. not your game-world border. if yes, Run That DFS again, and fill all blocks which DFS ...


1

The sf::IntRect that you will use will be the same for both directions. What will need to be changed is the scale of the sf::Sprite variable. You will simply need to do something similar to this: // Assumes that the image side is 24x32 and it is the first frame of the sprite sf::IntRect test(0,0,24,32); playerSprite.setTextureRect(test); if( walkingleft ...


2

This indeed should be very simple, so I suspect you may have gotten some details wrong. The overall goal is to match up the center of the camera with the midpoint of the players. As you've found though, those values aren't immediately available to you, so you need to work them out. What you might have are (leaving out the Y axis stuff since we don't need ...


2

Hexagons as a grid type are not uncommon in games, particularly games involving tactical elements. In a 4-way movement scheme, in order to move diagonally you have to expend two moves. In a 8-way movement scheme, you either have to make the diagonal moves have a cost of two, one, or a fractional sqrt(2) cost in resources. Hexagonal grids allow movement ...


1

You need to remember that C++ is a multi-paradigmatic (OOP, functional, procedural, ..) language and you should use the programming paradigm that best solves your current issue. OOP doesn't lend itself well to this problem. In OOP you think about single objects in isolation (concept of "a tile"). But most of your algorithms will operate on a whole ...


1

I would advise against using inheritance to manage different tiles. Imagine how annoying it would be having to define a new class every time you add seemingly different types of tiles. That would result in a lot of implementations for simple things like a grass or a dirt tile. It is much simpler and more maintainable to make tiles configurable. Define a Tile ...


0

(I cannot comment so I'm answering) If you build an array with reference for the types of the files (I don't know much of C++, so I'll pseudocode) tiles[0,0] = ref_to_fire_tile tiles[0,1] = ref_to_fire_tile tiles[0,2] = ref_to_grass_tile ... Where ref_to_*_tile holds a reference for a specific type of tile which inherits from a generic one, this way ...


6

It is fine to have lots of instances. An instance of a class without virtual methods is just like a POD C struct in terms of memory consumption which is similar to primitive data types. It is no problem. Your concern when instantiating many instances of a class are resource related I would think. CPU - should not be affected because you will be ...


0

To give an example to my comment public class Tile { //some variable stuff; public Tile() { //some constructor stuff; } } public class FireTile { //some variable stuff; public FireTile : Tile() { //sets player on fire //some constructor stuff ...


0

It sounds like what you want is named delegates. If I understand it correctly, your actions are just a call to a function in an existing component. Then all you need is to store a member function pointer and a pointer to the component, instead of a custom class. You can do this directly with member function pointers, or wrap it in a delegate class. It would ...


2

To send constant values to shaders without using the effect framework, you create constant buffers and bind them to the pipeline with (for example) VSSetConstantBuffers. For example: // You can of course eschew the structure, but this allows you to stuff more data // into the pipeline with a minimum of fuss; you should generally create constant // buffers ...


3

The following code should work: var points = new float[] { 0.0f, 0.5f, 0.0f, 0.5f, -0.5f, 0.0f, -0.5f, -0.5f, 0.0f }; int vbo = GL.GenBuffer(); GL.BindBuffer(BufferTarget.ArrayBuffer, vbo); GL.BufferData(BufferTarget.ArrayBuffer, points.Length * sizeof(float), points, BufferUsageHint.StaticDraw); ...


0

Message pack is a great alternative too! (http://msgpack.org)


0

Google FlatBuffers is an efficient cross platform serialization library for C++, with support for Java and Go. It was created at Google specifically for game development and other performance-critical applications. It is available as open source under the Apache license, v2.


0

If you are on a Linux platform, you can directly use json.h library for serialization. Here is sample code I have come across. Source: Json Serializer //============================================================================ // Name : JsonTest.cpp // Author : Manis Kumar Khedawat ...


2

I'm not sure if I should just delete the question since I solved it on my own or if I should leave it up for others to see in case they have the same problem. For now I am going to add my edit to this as an answer but if I should just delete the entire question let me know! I'm relatively new to Stack Exchange and am not really sure. The problem with the ...


0

Your top code chunk is: t2 * (t1 * direction * inverse(t1)) * inverse(t2) Your bottom chunk is: t3 * direction * inverse(t3) Given that t3 = t2 * t1 It's (t2 * t1) * direction * inverse(t2 * t1) As far as my knowledge of Quaternion multiplication goes, I don't think t2 * (t1 * direction * inverse(t1)) * inverse(t2) and (t2 * t1) * direction * ...



Top 50 recent answers are included