Jump to content
  • Advertisement

Pether

Member
  • Content Count

    55
  • Joined

  • Last visited

Everything posted by Pether

  1. Pether

    C# Enforcing input order?

    How do you create the random code? Do you have any way of knowing what code it is? Or are they just images? In some way you will have to know what the code is, and in what order they are. From there on there are several simple ways of making sure the user clicks in order. I guess the simplest would be to keep the code in a collection of some sort, array, list. And then loop through that collection while the user inputs, is the input the correct one? Continue one index up and try the next one. This make is easy to add more to the code, as well as resetting if the user entered the wrong code, just reset the index. If i understood it correctly.
  2. Heyo, I've been looking for a tool in which I can create tile maps, where I'll see the result in real time / per save so that it will be possible to see transitions between the different tiles directly, without needing to load them up in an editor / game just to check. Are there any tools like this? I have vague memories of seeing one in development a couple of years ago, but all I can find are mapping tools. I'm looking to make simple black and white tile maps at the moment. Preferred to be hexagonal tiles as well!
  3. Pether

    Computer Science or Game Development

    I believe it would be easier to get a job outside of gamedev with a cs degree, a lot easier then trying to get a job outside with a gamedev degree. A lot of the stuff you learn there aren't useful in many other areas, they are more a specified part of the field. GameDev is an happy dream for many, but does not result in a happy reality for even more. Better to have a job and a hobby, than 'nothing'. So for job security and your future, I'd go with computer science.
  4. Heyo, I'm new to Unity and have been wondering a bit on how to best structure the scripting part. What are the good practices? Bad? Currently I am adding a script component for each script which are based on what the script does, just to keep them apart and focused on their function. Ex. Have everything to do with combat in one script, selection in another, movement in one, etc. And then use getComponent on the object if i need them to communicate in some way. Is this ok? It seems kinda off, even though having the code keep their single responsibility usually is good.. Would it be better to use script component, and then add the other parts as regular classes in that script? Last night i found this example, is it a good way of working with unity? I'm not asking for a enterprise solution as i am just starting out with unity(but i work as a developer in c# & more), as i don't want to spend too much time when i have barely something to improve, just something to use as a guide in the future.
  5. For making games maybe gamemaker studio can be something? You don't need to know programming to start programming, as you can use icons that are equal to loops, actions and events.(sort of like scratch?), and when you get the hang of coding you can write your own scripts and do it that way instead.
  6. Pether

    Engine Switch

    https://www.humblebundle.com/gamemaker-rebundle Get that and you can do 2D games fairly easy, easier then U4 and Unreal, and there are plently of free resources on the internet, no need to spend any money.
  7. As long as you have evidence proving that you have programmed since your teens you don't need a cs degree. Show them a portfolio and a good cv with clients and work history. Though, i am sure many employees would pay you less since somehow a degree warrants a higher pay, but just push back on them.
  8. Pether

    What are bytes

    Do understand that you do not have to represent only one data with a byte/whatever you are sending over the net. One byte can hold information on 8 different things if you utilize the bits for information, and not the whole byte. Saves a lot of traffic. It is also possible to use one half byte, called a nibble, to hold information, thus holding information on two things in one byte in the ranges of 0-123 each. Also never ever send meta information if this will be known on client, why sent the name of a rpg item, if that name is already known on the client? Send the id instead. Also, when working with bytes it is good to understand bitwise operation so that you can easily get the information you need, or shift the bits to do faster calculations then when using regular arithmetic. https://en.wikipedia.org/wiki/Bitwise_operation https://en.wikipedia.org/wiki/Nibble
  9. Some time ago I bought a subscription on Mapt(gives access to all books and videos on Packt) and as I just got on my vacation I figured that I could just as well start up my game programming again. I have sort of already decided to learn myself Unreal Engine this time, as my earlier tried with Unity, GameMaker didn't result in anything worthwhile. Anyways, does anyone know of any good books/videos on Mapt to watch? Primarily on the unreal engine, but more abstract game development stuff is also welcome. Could also be clips on Youtube or other places though! Thank you.
  10. Pether

    MODS and private server on resume

    Private servers are usually illegal since they rely on stolen server software. So no, i don't think any company is interested in hiring people who do illegal stuff and try to brag about it.
  11. Pether

    How do Open World games work?

    Another thing is that the world isn't really living beyond where the player can interact, you don't have the inhabitants in the cities on the other side of the map doing their stuff, but it's later simulated and calculated when the player gets there. So the world can be gigantic, but it's simply put just a small part of it that is active at the time.
  12. Eh?       Easy way is to use libraries so you don't have to think too much yourself. For example this: http://libnoise.sourceforge.net/tutorials/index.html
  13. Pether

    Learning C++, Terrain Generation

    Check this out. http://libnoise.sourceforge.net/index.html
  14. Pether

    How to generate biomes?

    Then learn how to use Perlin noise.
  15. Gamedev isn't all about C++, it's the AAA-companies that mostly are, since they have been. Indies use whatever they chose to, so C#, Java, whatever.   If you already know Java i'd recomend LibGDX which is an awesome library and lets you develop to all platforms at once. Unity uses C# to script, so it's not programming per say, and a lot of the stuff is done with the editor, while in LibGDX it's programming from the start to finish. If you'd want to do 3D games in the future go with Unity, otherwise LibGDX.   As for what games, i started with Asteroids, it offers a lot of potential to develop ontop of the original idea. You talked about AI, implement AI for enemies, chasers, scouts, fleeing, patrolling, avoid asteroids, etc Another game that allows more to be build ontop is Space Invaders, can be built into whatever sidescroller you want basically.
  16. Why wouldn't UE4 support 2d? 2d in DX11, Unity and UE4 are all just 3d but you are not using one of the dimensions.
  17. I have tried it using this method: http://www.angryfishstudios.com/2011/04/adventures-in-bitmasking/ But that way is pretty hefty, especially if you have several terrain types.   So I thought of trying the method here, which uses transparency in the tiles: http://www.gamedev.net/page/resources/_/technical/game-programming/tilemap-based-game-techniques-handling-terrai-r934   I am wondering if anyone has had any experience with auto-tiling? What method did you use? Would you recommend it? I have also been thinking of texture splatting, which age of empires uses, worth it?
  18. Yeah, i have heard some people do it like that, and have thought about it myself. Seems like a simpler version of the second link i posted. But i am having thought about how that would actually work if you have a lot of different layers for the different terrain, having to loop trough each one and draw, instead of having it all calculated in a single one. I am making a large scale rts with procedural terrain that gets generated on the fly, so it's a bit more that will be done then in a handmade rpg?
  19. Heya,   no, I haven't got it to work. But I haven't had any time to look at it since last time as I've had three assignments due today and another one this weekend. In a world with unlimited time I would have created a better environment to test the pathfinding, showing all the values and behind able to create obstacles and new paths while it's running, but haven't had time to do that. But I have thought of doing a desk test since the fault most likely lies somewhere in the code that calculates the costs of moving, so I should be able to see where if I just write it down.     I cut the code down to the bare minimum to run and show the pathfinding. https://www.dropbox.com/s/to7ljzjiuzlxlbd/Gamestuff.rar?dl=0   *edit*   I actually got it to work correctly, turns out the sortfunction for the vector didn't work as planned so I replaced it.
  20. So I decided a few days ago that i would write my own implementation of A* since my earlier luck trying to add other peoples code and refactoring it to it'll work with my game failed all the time and only worked as time sinks.   I followed this guide here: http://homepages.abdn.ac.uk/f.guerin/pages/teaching/CS1015/practicals/aStarTutorial.htm   I am not really sure where the problems occur, but looking trough the open list it seems duplicates gets added even though i have a check that wouldn't enable that behavior. The algorithm just keeps going until i stop it, having thousands of Nodes in the lists from a 15 by 15 map. (The size is currently hardcoded)   Pathfinding.h #include <vector> #include <algorithm> struct Position{ Position(){} Position(int x, int y){ this->x = x; this->y = y; } int x, y; }; class Node { public: Node(Position pos) { this->pos = pos; } Node* getParent() { return parent; }; void setParent(Node *parent) { this->parent = parent; } Position getPosition(){ return pos; } int getFcost(){ return g + h; } int getGcost(){ return g; } int getHcost(){ return g; } void setGcost(int g) { this->g = g; } void setHcost(int h) { this->h = h; } bool operator < (Node& str){ return (f < str.getFcost()); } private: Position pos; int f = 0; int g = 0; int h = 0; Node *parent; }; class Pathfinding { public: Pathfinding(){}; bool findPath(Position, Position, std::vector<std::vector<int>>); std::vector<Node*> getPath(){ return path; } //void checkNeighbours(Node*, Node*); void addToClosed(Node* current){ closed.push_back(current); } void addToOpen(Node* current) { open.push_back(current); } void removeFromOpen(Node*) { open.erase(open.begin()); } int calculateManhattanHeuristic(Position current, Position target) { return (10 * (std::abs(current.x - target.x) + std::abs(current.y - target.y))); } Node* getCurrentPoint(); bool inClosedList(Node*); bool inOpenList(Node*); private: std::vector<Node*> open; std::vector<Node*> closed; std::vector<Node*> path; }; Pathfinding.cpp #include "Pathfinding.h" bool Pathfinding::inClosedList(Node *current) { bool inClosed = false; for (int i = 0; i < closed.size(); i++) if (closed.at(i) == current) inClosed = true; return inClosed; } bool Pathfinding::inOpenList(Node *current) { bool inOpen = false; for (int i = 0; i < open.size(); i++) if (open.at(i) == current) inOpen = true; return inOpen; } Node* Pathfinding::getCurrentPoint(){ std::sort(open.begin(), open.end()); return open.at(0); } bool Pathfinding::findPath(Position startPos, Position targetPos, std::vector<std::vector<int>> map){ // Add starting and target position as Nodes. // No check if it's blocked or if they are the same yet. Node *start = new Node(startPos); Node *target = new Node(targetPos); // Add the start Node to the open list. addToOpen(start); do{ // Get the Node with the least F-score. Node *current = getCurrentPoint(); // Removes the current node from the open list. removeFromOpen(current); // Adds the current node to the closed list. addToClosed(current); // Creates temp neighbour Node, initializes g-cost to 0., creates node to see if it's diagonal movement. Node *neighbour; int newGcost = 0; bool corner; // For every position in a 3x3 area, all neighbours plus current position.. for (int x = -1; x < 2; x++) for (int y = -1; y < 2; y++) { // If it's the current position, skip. if (x == 0 && y == 0) { continue; } // If the neighbour's position is outside the map, skip. if (current->getPosition().x + x < 0 || current->getPosition().x + x > 14 || current->getPosition().y + y < 0 || current->getPosition().y + y > 14) { continue; } else{ // If the neighbour's is not blocked.. if (map.at(current->getPosition().x + x).at(current->getPosition().y + y) == 0) { // Check if diagonal. if (x != 0 && y != -1 && y != 1) corner = true; else corner = false; // Create neighbour at position. neighbour = new Node(Position(current->getPosition().x + x, current->getPosition().y + y)); // If the neighbour is not in the closed list. if (!inClosedList(neighbour)) { // Add G-cost dependand on corner, diagonal from current position. if (corner) { newGcost += 14 + current->getGcost(); } else newGcost += 10; // Add the G and H-cost. F-cost is calculated in the Node-class, getFcost(). neighbour->setGcost(newGcost); neighbour->setHcost(calculateManhattanHeuristic(current->getPosition(), target->getPosition())); // If neighbour is not in the open list. if (!inOpenList(neighbour)) { // Set current Node as neighbour's parent. neighbour->setParent(current); // Add neighbour to the open list. addToOpen(neighbour); } // If neighbour is in the open list. else { // Calculate new G-cost.. if (corner) { newGcost += 14 + current->getGcost(); } else newGcost += 10; // If the new G-cost is better then old G-cost for neighbour, change parent. Cheaper path found. if (current->getGcost() < neighbour->getGcost() + newGcost) { neighbour->setParent(current); } } } } // end neighbour blocked if. } } // Continue to look for a path until Open list is empty, there are no more Nodes to check. } while (!open.empty()); // If target Node is in closed list we have found a path. if (inClosedList(target)) { // Reverse the path trough the targets parents until we have gotten to the start position. // Set as path, get path with getPath(). Node* reverse = target; while (reverse != start) { //I noticed now that i hadn't completed this part. path.push_back(reverse); } // Return true as we have found a path. return true; } // Return false as we have not been able to find a path. else return false; } I am at loss at what to try next...
  21. I worked all evening last night on trying different ways to pass a 2D array that contains map information to my A*-implementation. The ways that work requires me to send a pointer of pointer arrays(**a), but that can't be the bets solution since i have to delete the pointers afterwards, and i could only get it to work with my own types and not int/bools. The last thing i worked on was using a template, but that went all haywire spitting out every type of error there is in history of mankind.   This is what that code looks like, and if it works it seems to be the most efficient way of doing it. .h template<size_t size_x, size_t size_y> bool findPath<int, int>(Position startPos, Position targetPos, &int(mapArray)[size_x][size_y]); .cpp template < size_t size_x, size_t size_y > bool Pathfinding::findPath<int, int>(Position startPos, Position targetPos, &int(mapArray)[size_x][size_y]){ ... I have googled to my last breath and have modified it in many different ways, but it's my first time working with templates. I have tried the ways posted here: http://stackoverflow.com/questions/8767166/passing-2d-array-to-function   If i cant get this to work I'll have to switch back to sending vectors instead of arrays and that is way too painful.
  22.   Diagonal is 14 cost and horizontal/vertical is 10, so same cost. But i tried changing diagonal to 24, and even 50. It still gives the same path, even gives a path that almost only has diagonal path's. I also tried changing all horizontal/vertical costs to 200, but still gives same path's.. It seems it gives 3-4 different paths no matter the cost?   And even so, if it moves away from the target, going up, the h will get higher, and thus it won't be picked as the next?
  23. I have gotten it to 'work'. This is the path it gives me: https://www.dropbox.com/s/vfwx5ee1vqzauhv/failpath.png?dl=0   As you can see it gets to the target, but it does so by doing some strange things. Is the heuristic wrong? Because it goes away from the target?   Blue : Start. Red : Target. Black : Blocked.   Also, it seems to be checking all nodes on the map..
  24.  Ah. Ok. Yeah, i noticed what you meant there and have fixed it.   *edit*   I found the problem i was having. I was going checks: closed.at(i) == current This will be true if all the variables were the same, but since they would have different costs it wouldn't return true. I instead checked to see if the pos.x and pos.y were the same. Bam. Now to fix some other stuff to see if it works as it should.
  25.   Ah, fixed that.   The newGcost is checking to see if the cost to get the the neighbour is cheaper if i go from the current node (the + g cost i am doing), then the current path to the neighbour node.   It's the 6'th point on the guide: http://homepages.abdn.ac.uk/f.guerin/pages/teaching/CS1015/practicals/aStarTutorial.htm  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!