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!


Member Since 29 Sep 2012
Offline Last Active Yesterday, 02:41 PM

#5222987 Seemed easy, is really hard, How do you program bullets?

Posted by KnolanCross on 13 April 2015 - 12:38 PM

Are you using any physics engine? Maybe you could consider using one, I know that box2D has special behaviors to deal with bullets.

The only thing I can add to the discussion is that you need destroy the bullets even in case they don't collide with any other object (for instance, the player start shooting into the sky and there is no ceiling in your game). If you don't do this you will have performance issues sooner or later for handling hundreds of bullets that are traveling "to the infinity and beyond" =)

#5217337 Game engine for Linux?

Posted by KnolanCross on 18 March 2015 - 07:25 AM

I guess you need to give more info about what kind of engine you are looking for.


Most 2D engines will run on linux, as for 3D the open source ones tend to run as well.

#5214930 PathNodes: array or list

Posted by KnolanCross on 06 March 2015 - 05:42 AM

Assuming you are talking about A*, you will use more than one container for the pathfinding, you will need one to represent your scenario, one for the open list and one for the closed list.


The simplest solution is to use a grid to store your nodes and represent your scenario (assuming all your nodes have the same area size), where node of position x, y can be directly translated to the grid x, y index. A grid has two problems, the first one is that it will use a lot of memory, the second is that you will have a lot of nodes.


The best container to keep an open list a heap, since it will always recover the node you need in O(1), inserting an element in a heap is a O(log n) operation. Just keep in mind that you will need a modified heap, as you need to update the node cost (you can also update the values and call the heapify operation, if your implementation allows it).


For the closed list I like to use a list and a flag in the node, once I add it to the closed list I mark the flag and add it to the closed list. This approach is good because the only information you need for the closed list is if the node is in it. In the end of the pathfinding I go through all the elements of the list, reseting the flag.

#5211949 Problems implementing A* - Need a knowledgeable eye to look at my code

Posted by KnolanCross on 20 February 2015 - 12:33 PM

My point is, why on diagonals you add the current->getGcost(); and not on straight lines. Also, you never reset this value/set it to a initial during your whole neighborhood loop.


At least in my implementation I always SET it nodeG + the distance between the two nodes. I don't add it to a buffer, hence I use "=", not "+=".

In you implementation it seems to me it should be:

if (corner){
    newGcost = current->getGcost() + 14;
else {
    newGcost = current->getGcost() + 10;

Again, I may be wrong here, but the way it is in your code really didn't made sense to me.

#5211945 Problems implementing A* - Need a knowledgeable eye to look at my code

Posted by KnolanCross on 20 February 2015 - 12:17 PM

I just took a  quick look, here are the bad smells I could find:


Not using it, but here should be h:

    int getHcost(){ return g; }

I could not understand the logic of yout newGcost update, maybe you should double  check it.

#5210445 Very basic 2D RPG game

Posted by KnolanCross on 13 February 2015 - 05:04 AM

Google for (those requires nearly no coding skill needed):

- RPGMaker

- GameMaker

- Construct2


If you want to code the whole game, I would suggest that you start here:



Very well written step by step tutorial using pygame. As for graphics, if you don't want to release your game (personal game or just show to a few friends) you can get the ripped sprites from google (just google for pokemon sprites). If you want to release your game, then you will have to find some free sprites, opengameart is a good place to start.

#5200049 Success Story, need advice from here

Posted by KnolanCross on 26 December 2014 - 06:35 AM

What I would do is offering a small amount of in-game currency and some in game item that have a reference to my other game if people download the other game. The item must not be powerful, but it should be fun or goofy.

For instance, say your famous game is a racing game and your new game is a pre historian game. Give players of the famous game a tyrannosaurus' roar horn for downloading the new game.


IMO, that would get people curious to play your new game, which wouldn't happen if they got only in game currency (in which case they would likely to download the game, get the reward and never touch it again).


That being said, keep in mind that I am not a famous game developer, this opinion was born of my experience as a consumer.

#5197557 Using python for mobile GameDev

Posted by KnolanCross on 11 December 2014 - 06:39 AM

I have been using Kivy for one year now for a scene editor and I would not recommend it for a game.  It is a great UI framework and I really like it, but it is not a game engine. You won't have many useful features (for instance, collision detection) and you won't find many topics on specific game problems.


I would stick to pygame if I were you.

#5197544 Help with 2D pathfinding

Posted by KnolanCross on 11 December 2014 - 04:09 AM

I have a simple A* implementation in C in my long dead blog:



It may be useful.


There are 3 paths you can follow (no pun intended):

1) Use a grid + A*, consider tiles where an enemy is as not walkable, recalculate each frame. This is the slowest* one possible, but since your map is pretty small, I don't see it being a problem. You can also easily optimize it by saving creating a grid "version". You start the grid as version 0, each time it changes you update the grid version. Save the paths with the information of which map version it was created, if it changes, you need to recalculate the path.

2) Use a grid + A* to find the path and then use steering behaviors to keep enemies from colliding.

3) Use only steering behaviors. You can set the agents to avoid the static objects, but in my experience, it is very annoying to get the weights right.



* PS: Please notice that for a lot of games, the "slowest" path finding solution is still fast enough. Heck, I have used floyd-warshall (which is away slower than A*) in some prototypes in the past and it was fast enough.

#5189744 Current state of custom and commercial game engines as of 2014

Posted by KnolanCross on 28 October 2014 - 12:29 PM

So, one of my questions is, is it worth still to make a custom game engine for yourself or even to think about making it open source or commercial ?


Very unlikely, forking an open source engine to make your own may be a good idea, but I can't really think of a good reason to do so, also many have licenses that would forbid that you add features without releasing them as open source.


The point on this whole topic is that it has been a long, long time that people have started developing engines, so they have a giant upper hand against anyone who wants to start now. I support open source engines and am quite active on development of tools, tutorials and answer question to the one I like (shameless hook: look at my signature to check the engine), but I am very aware that if I wanted to create a serious game (to earn money to keep myself alive, not as hobby) I wouldn't go for an open source solution, specially if we are talking about 3D.


As for your own situation, I think this is the best time ever for you. Since most engines work with plugins, you can definitelly work on a commercial plugin and make a decent amount of money with it.

#5189736 UnboundLocalError: local variable 'comp' referenced before assignment

Posted by KnolanCross on 28 October 2014 - 11:43 AM

No problem.

pc=comp() & whowin(you,pc) will work.

But keep in mind that there is no need to save characters, you could rename the comp function to something like get_computer_hand.


Finally, there is a program called "pyflakes" that will check for errors, you could use it: https://pypi.python.org/pypi/pyflakes

#5189712 UnboundLocalError: local variable 'comp' referenced before assignment

Posted by KnolanCross on 28 October 2014 - 09:43 AM

1) You have a function with the same name of a variable, which is a very bad idea.

2) You should check the user input as soon as it is entered, not after you processed the round.

3) You can replace the second end third ifs of the comp function by if, elif and else.

4) The parenthesis of your whowin function are wrong, here is an example:

>>> comp = "rock"
>>> you = "scissor"
>>> comp == ("rock" and you == "scissor")

What python is interpreting in this code is:
"rock" == (bool("rock") and you == "scissor")
"rock" == (True and True)
"rock" == True


you probably meant:

(comp == "rock" and you == "scissor")

#5176814 Include file not found in GCC, due to path size?

Posted by KnolanCross on 28 August 2014 - 08:55 PM

You can also set the paths in the include search path of code::blocks. I use to do this in my linux/windows projects.

#5172204 Tile-Based Games - Slope

Posted by KnolanCross on 07 August 2014 - 11:46 PM

Personally I would save myself the trouble and just use box2d to handle the collisions.


Nice reading, and great points. Still I keep my opinion, assuming I would be using the engine I am used to - orx, which uses box2d - I think it is far easier to use the custom tools. Here is my view on each of the topics, considering my former experiences:

Moving Platform Hell - Indeed, platforms are hard to code, two things I would point is, you can have a collider that is not solid, so you are just informed that a collision occoured, using that would allow to determine when the character is on the platform (touching and falling, ok, stop) and code gets easier. Other than that, most engines have the option the reparent an object to another, and they will move together, on orx it is called attach.
Finally, I would like to point that programming it from the scratch would not be easy too.
Walking on Sunshine, Not - Pretty easy to create a fill algorithm to determine the collision forms in your scenario assuming all your slopes are in the same ratio. Use a mesh instead of loads of boxes and you avoid the corner collisions (in all fairness I did had this problem once*).
Tilemap Collisions Ain’t Easy - Same as above.
Physics contact detection is expensive - True, but is not likely it will bottleneck your game. At least in my experience, heavy use of transparencies and particles would kill my performance, not physics simulation.
Physics are alwaaa-a-a-ays glit-tch-tch-tch-y - Tell me again how your new code of collision detection, jumping, running, gravity is guaranteed to be 100% bug free.
There’s got to be a speed limit on everything - Using a set speed instead of adding forces solves this problem, or at least solved for me.
Tweak the hell out of this world - Same as above, and again, you can simply detect collisions and turn off the auto solve part of box2d.
Speaking of Movement - Not sure what to say here, yeah the lib won't read your mind and create exactly what you want outside the box, I guess this is expected. Also, not using the engine, you will have to code things anyways, so I don't see the huge advantage. Finally, his main example of bouncing is just about setting variables to 0 (and in orx case, they default to 0).
Is it too early or too late? - Not much to say, you can set highspeed flag to solve the problem he described.

I can understant the guy's points, I had a lot of trouble using the built in physics the first time (reading this articles, I remembered most of them). But still, I solved them all, and they mostly were because I was using the lib wrong and now that I learned it, I wouldn't imagine creating code for things like collision from ground zero. And even if you don't like the physics simulation, as I said, just turn it off and just use it to detect collisions.

* Video here: https://drive.google.com/file/d/0B0UdeUM9pB-nUk8wVmJMTE4xSmc/edit?usp=sharing

#5171432 Need Help Fixing Problem With Simple Program(Python/Pygame)

Posted by KnolanCross on 04 August 2014 - 10:36 AM

Assuming the code you paste is correct, the problem is that the actual drawing code is outisde the main loop.


The short answer is:

Add a single tab (or four spaces, depending on what you are using to indent) to every line from line 44 to line 64.


The long answer is:

Python takes context by code indentation, in the code you posted here, your program will loop in the wait for the close click event, and won't draw a single thing. When the user press the close, it will leave the loop and execute the drawing code ONCE (hence, you see the drawn there) and then quit. You need to put the drawing code inside the main loop to see it actually draw something.