# suliman

Member

1421

1659 Excellent

• Rank
Contributor

• Interests
Art
Design
Programming
1. ## A* pathfinding: nodes instead of grid?

I guess its the "find adjacent" and "adjacent costs" i need to fix. (i dont have it in front of me right now:). More info will follow! But in the grid version i just give the pather the pointer to the start of the 2D-array holding map data (terrain type for each tile) so now maybe a pointer to the array of all the nodes? I assume it's best to calculate the adjacentCost (cost/distance from a node to each of its linked nodes) beforehand and store them (in each node). Otherwise I need to calculated such distances thousands of times each pathfind. When it was a grid i just used the adjacentCost of "1" (or 1.41 for diagonal movement) so no calculation was needed. So something like: class pathfindingNode{ int id; int posX, posY; int adjacent[MAX_ADJACENT]; //the adjacent nodes(IDs) possible to move to. id -1 means no node at that slot float adjacentCost[MAX_ADJACENT]; //cost to move to an adjacent node };
2. ## A* pathfinding: nodes instead of grid?

Im using micropather, a c++ implementation of a* pathfinding in my games. I got it to work fine with a strict grid-based system, but now need it to also work with "nodes". My setup is like this: 1. I have a collection of nodes. Each node has a X/Y-position, an ID, and an array of max 10 node-ids it can move to ("adjacent nodes"). 2. Which nodes are reachable from each node are checked (based on a max distance and not having any obstacles between them). 3. Cost to move from a node to another is simply the distance between the 2 nodes' positions. I guess some things will be silimar to how a grid works, but im not sure how to reconstruct the code.
3. ## C++ Savegame headers?

Hi Im using binary files to save and load savegames. But when you list your savegames for the user you want some metadata such as date/time, gameday, difficulty, map name etc so the user more easily can identify which savegame they want to load. What is the prefered way of doing it? 1. When saving, save metadata first in the file. Then do a function "scanSaveFiles()" before showing the available savefiles for the user. This will read each "header" of each file (reads the first section of the binary file without actually loading that game) and can then show the info to the user. 2. When saving, update a table of savegame-metadata held by the "gameMaster" that holds other stuff like user options, progress etc. However this seems bad since if the user manually moves or modifies the savefiles the table of savegame-metadata will no longer sync with the actual save files. Or any other smarter way of doing it?
4. ## Progression in racing game: keep money and upgrades between races?

Thanks for your feedback! Useful input.
5. ## Progression in racing game: keep money and upgrades between races?

Consumable upgrades is the same as my suggestion 2 i guess (buy upgrades/weapons for each race). Having upgrades weak or very expensive (=player gets less upgrades) just makes upgrades less impactful, which is not very fun for an arcade game (but would make sense in a simulation). It's halfway to just removing upgrades alltogether. You want to feel the difference when getting something new. Giving the loosing player a boost by giving him/her more money might work yes, but it's a bit strange lore-wise Then it would make more sense to give all players the same upgrade-resources like i suggested (maybe just call it "time" as in "time spent in workshop" to upgrade and improve your vehicle").
6. ## Progression in racing game: keep money and upgrades between races?

Hi Im designing a arcade topdown racing game in the tradition of rock and roll racing (SNES), super cars 2 (AMIGA, PC) etc. You run a "campaign" of linked races, and you can upgrade, buy weapons and gadgets etc. There is both powerups on the tracks and stuff you can buy inbetween races. This is set in space with lasers and small spacecrafts but the logic is the same. How to hadle progress/upgrades/investments? If the player earn money from success (getting a good placement in a race), the player who starts off well will be able to buy better upgrades and weapons and it will be even harder for the other player to catch up later in the campaign (two players and many AI are allowed in the game). This is how it's done in super cars but im not sure it's good design. Some ideas could be: 1. Upgrades are persistant between races for the entire campaign, but each player get the same amount of money/resources no matter how well they do in the races. 2. Like above, but each player gets some fixed points/money to invest in each race for upgrades/configration/weapons: next race the crafts are reset. So you can try out a completely different loadout each race or build something you have already tried out. If you can choose different vehicles I get even more options:) I could replace some upgrades (like "better engine"/higher speed) with just having different vehicles: "shiptype X" may move faster, but cost more so less money left to stock up on missiles for the race ahead. Thoughts?
7. ## Pirate game: treasure hunting mechanic

Thanks guys! Some good thoughts. Any more input is always appreciated.
8. ## Unresolved external symbol?

yes it does. I continued to clean up and now it works (even with the body in the h-file). I think I had a reference to an old version of it that was local and not the standardized version i now use (#include "file.h" instead of #include <file.h>). This is one of my big problems with C/C++. It's so easy to get stuck on code administration (linking, include order, circle reference etc) It takes time (especially when reviving an old project that had a slightly different code architecture). Thanks for your help!
9. ## Unresolved external symbol?

Cool! Commenting out that call allows for it to compile. But what can be wrong here? That file (with the constructor for gameInventoryMaster) is included in all my project and those work without commenting out the call togameInventory::setSingleSlot(). Why is it now not allowed? I moved the body of the contructor (of gameInventoryMaster) to the cpp file (from the h file) and now all projects compile. So im confused, what could have have done here?
10. ## Unresolved external symbol?

Hi Having coded alot, i still get stuck on these things sometimes. I've restarted an old project so I needed to clean it up, fixed paths etc before it could compile. I still have one compile error: Error 1 error LNK2019: unresolved external symbol "public: void __thiscall gameInventory::setSingleSlot(class int2)" (?setSingleSlot@gameInventory@@QAEXVint2@@@Z) referenced in function "public: __thiscall gameInventoryMaster::gameInventoryMaster(void)" (??0gameInventoryMaster@@QAE@XZ) C:\Dropbox\PROJECT\code\games\racing\source\gameMaster.obj May it be a circular include or something? The function "setsingleSlot" is defined in a file called "inventory.h" which i dont have any references to in my project, so im a little stuck here. Any ideas? Happy holidays ya'all!
11. ## Pirate game: treasure hunting mechanic

Im doing a carribbean pirate game in the tradition of sid meiers pirates. In THAT game, you would buy pieces of treasure maps in taverns, and when you had all four you could see on the map where in the gameworld you should travel to find the tresure: you went there and got the treasure. Each "rival pirate" (there were 9) could be fought and defeated and also had a treasure you could find with the above method (defeating them and finding their treasure was independant from each other. Any ideas on how to mix this up for my game? I want famous pirates (10-12) rooming the world that you can defeat, and maybe their buried treasure should be linked to defeating them instead of buying map pieces? Another idea is to have rumour you buy from tavern reveal different things about a treasure location, such as: 1. close to which port (eg. "close to Port Royale") 2. direction relative to that port (eg. "south-west of it") 3. Distance from that port (eg. "12 leagues from it") Im using a simple 2d travel map as game world (satellite photo) of the carribbean which the players traverses. It's more fun gameplay to link together evidence such as those 3 above than to collect 4 map pieces and then place a marker "treasure is here" on the travel map (that feels to direct and guided). Once you have the idea of more or less where it is, you approch the beach there. If its close enough your crew finds the treasure. If not you just leave the beach. Sp you CAN find it without the 3rd piece of information but it might be harder. Or to get info about the treasure not before you defeat the pirate in question? (As a payment for not killing him?) Or tavernfolk only start to reveal info about the treasure after the pirate owning the treasure is defeated (since they are scared of him killing them)
12. ## C++ Unique identifier for functions? (c++)

Thank you all for your answers. I'll implement something from this
13. ## C++ Unique identifier for functions? (c++)

@Mike2343 But what would be the actual benefit over using my crude string comparison method?
14. ## C++ Unique identifier for functions? (c++)

Hi I've built a system for handling gui-popups that the player can answer to. The popup when called sets an "popup id" so i can check for that popup being answered elsewhere in the code like so: if (timeToEat()) callPopup(13, "What to eat?", "Cake", "Cookies!"); //elsewhere in code if (popupAnswered(13,0)) // clicked first button in popup eatCake(); if (popupAnswered(13,1)) // clicked second button in popup eatCookiesDamnit(); So i just increase the id (in the example it's 13) when adding more popups. This isn't ideal of course but I don't want to add defines or enums to identify the popups. Adding new popups should be easy. Another idea is to set a string value when calling a popup and check for that string to be exactly the same (the string will be the ID instead). Would that make sense? What else could I do? See below for string identifier example: if (timeToEat()) callPopup("popup_eat_question", "What to eat?", "Cake", "Cookies!"); //elsewhere in code if (popupAnswered("popup_eat_question",0)) eatCake(); if (popupAnswered("popup_eat_question",1)) eatCookiesDamnit();
15. ## Soldier creation in a medieval city -builder

Yes forming soldiers is not instant, also you cannot form any more soldiers during an attack, so the barrack limit at the start of an attack is what you have to contend with (and between attacks, your soldiers doesnt do anything). Combat will be pretty simplistic. But I might have some damage ratings like seen below. Basically anti-light, anti-armoured, anti-structure Weapon (and dmg-factor vs unarmoured/ leather/ metal/ building) Spear 10 7 4 4 Sword 14 12 10 6 Bow 10 7 4 1 Crossbow 10 10 8 1 Catapult 5 5 5 10 Ballista 10 10 10 3