Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

271 Neutral

About Assassinbeast

  • Rank
  1. Hi, im making a simple snake game where all GameObjects are placed on a grid of columns and rows. There are different 3 GameObjects: SnakeBody, SnakeHead and a cheese to eat.   When the snake eats the cheese, then the cheese have to find a new available spot to spawn. Note it cannot spawn on top of a SnakeBody or the SnakeHead.   So what is the best way to find an available spot for the new cheese to spawn? I have so far 3 different methods i mind:   Method 1 Get a random column and row, and then check if that spot is available, if not, then iterate it over and over again until it finds an available spot.   Pros: if there are a few Snakebodies on the map, and there are many available spots, then the chance of a single iterationcheck is pretty big and an available spot is found very easily.   Cons: If the grid is almost full of SnakeBodies and a very few spots are available, then the chance to find an available spot is pretty low and the program could even check the same spot multiple times because its a random check which can be so much waste of processingpower.   Method 2 Create a List(C#) and iterate over the whole grid. Add every Spot to the list that is available, then get a random number from 0 to the amount - 1 in the list, and then set that new cheese to that position. Clear the list after its done.   Pros: Unlike the Method 1, It doesn't matter how many spots there are taken or not, the count of iteration will always be the same.   Cons: The bigger the map is, the slower the program is gonna be. So if the grid was 100000x100000, it would need to iterate and add spots MANY TIMES, and then the Method 1 would be a better choice if the grid was that big.   Method 3 Create a HashSet<Point> at the beginning before any GameObjects gets created on the map. The Point contains the X & Y to determine if an exisiting Point is already in that HashSet. Add all the Points of the grid to the HashSet. When GameObjects spawn, then remove the Point of the GameObject in the HashSet, and add it back when the GameObject gets destroyed or moved. When the snake eats the cheese and need to find a new position, then just find take a random number from 0 to the HashSets Count - 1 and get that Point of it.   Pros: When you need a random position, you have them in the HashSet, and then you just need to take a Point out of it from a random index, .   Cons: Everytime something moves, it needs to remove and add (which is pretty fast). Also when you want to take a random object out of the HashSet, then the bigger the random index is, the slower the algoritm is gonna be, because you cannot just take the index and get the object directly out of the HashSet, you must iterate over it.   ----------------------------------------------------------------------   So every method seems to have its Pros & Cons, but is there a way better algoritm to do this stuff?
  2. Assassinbeast

    10 Ways To Improve Your Indie Game Development

    The step 4 is totally wrong. Be careful with the demos, because if your demo is revealing too much, the customer might not even buy it since he already played it.
  3. Assassinbeast

    What software is this?

    hello, does anyone know what software this guy is using to create this diagram? at 0:55   It looks extremely awesome, and very good to give a good overview.
  4. Assassinbeast

    Starting C#

    i highly recommend the book Illustrated C# 2012 by Daniel Solis. That book is straight to the point on every topic if you want to learn C# fast. Hes very good to explain the concepts with illustration and images. Its also a very good reference book and very unique because there are useless text in it, but just straight text of what you need to know.   I think the book is perfect for you since you have experience in programming and know what it is about.
  5. Assassinbeast

    Indie tutorial: Starting a project and forming a team

    Good article, thanks for sharing your knowlegde and experience!
  6. Assassinbeast

    How important is the iostream in gamedev?

    Ok, thank you people :)
  7. Hello folks :-)   I just wanna ask how important it is to learn/master the basics of iostream in c++.   eg:   cin.fail cin.good cin.clear cin.bad cin.putback cin.get cin.getline cin.eof    and all that bullshit.   for me, its kinda hard to remember because i never use it when i make games, and i never use it when i test my own code (only cout and cin), but sometimes when i read books, they use it. So its getting  hard and frustrating to remember how the iostream is made and when the states are set.
  8. Assassinbeast

    is class templates made in gamedevelopment?

    ok    thanks everybody for the help 
  9. Hello    I just learned templates, and i know quite abit right now.   So i just wanted to ask if there is any situation where you want to make your own class template. Becasue vectors already exist, and i cant really imagine when you should even need to define your own class templates.   But i know defining your own function templates are very useful in alot of kinds situations
  10. ahh ok, thanks everybody
  11. Hello.   I just made my small gameengine in c++ with sfml, where i have made menus, butttons, gamestates and such. There are a lot of different files, and some images.   So i how do i reuse it when i have to make a new game? Should i just copy the header files,cpp files, image folders etc into my new project? If so, that would be tedious like to link every project with sfml...    Btw, I am using microsoft visual studio express 2010.
  • 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!