Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

ByteTroll

Member Since 13 Sep 2012
Offline Last Active Yesterday, 09:49 PM
-----

#5043649 Am I a bad programmer?

Posted by ByteTroll on 16 March 2013 - 04:51 AM

The question shouldn't be "Am I a bad programmer" because it may be that we were  ALL bad programmer when we're just learning.  I know I was.  

 

But, at the time, I didn't realize I was a bad programmer (this was before the internet).  I would have probably been proud of my work, but that's because I didn't know...what I didn't know (Reminds me of the Oscar Wilde quote, "Youth is wasted on the young.")

 

Anyway, the question you should be asking is "Am I an experienced enough programmer to provide tutorials?"  Because "bad" and "inexperienced" often could be seen as going hand and hand.

 

Couldn't have said it better.  Everyone was once a bad programmer.  Even good programmers have room to improve -- you are always learning.  With that being said, BeerNutts is right.  The question is "Am I an experienced enough programmer to provide tutorials."  Even if you can answer that question with a yes, you have to realize that this is the internet, and on the internet, you are going to get critiqued.

 

 

 

Someone could get upset at a hello world app tutorial because an application that only writes out a line of hard coded text is essentially useless, but that is not a reflection on the tutorial's quality.

Very true -- I would just chalk it up to "haters gonna' hate" and move on.

 

Finally, like a lot of people, I would advise against the "System("pause")" call.  Unless the tutorial is specifically about the Windows, and even then, there are better ways of doing it.




#5032740 C++ game from scratch in 3d with models

Posted by ByteTroll on 15 February 2013 - 12:17 PM

Seeing as everyone above me has already given great answers, I will just reiterate.  You need a solid grasp of your language of choice, the libraries you choose (if you choose any), paradigms, algorithms, etc.

 


and also atleast give me a source for a begineers to start off

You really need to use Google and do the research for yourself.  Regardless, this should get you started:

https://github.com/id-Software/DOOM-3-BFG

 

This is the complete source code to Id Software's Doom 3 BFG edition. This contains the entire engine and game code, but no assets.  If you are going to take a look at the Doom 3 BFG codebase, you might also find this code review helpful.

http://fabiensanglard.net/doom3/index.php

~Byte.




#5004245 Databases in your games

Posted by ByteTroll on 26 November 2012 - 11:43 AM

Databases are not the be-all and end-all of storing information.

I'd suggest looking into building a simple tool set that stores your data in a custom format or leverages an existing tool like XML/JSON/YAML/etc. You can knock together a tool to edit your game content in C# in a few hours; in the same time it'd take to integrate a database, design a schema, and start filling out "forms in a database", you could have some custom solutions that do precisely what you need and can be extended as you see fit whenever you like.

For perspective, most major game engines use custom data storage systems for precisely these reasons.


I agree with ApochPiQ. I worked on a game where we used MySQL databases to manage everything -- quests, stats, players, items, etc. If I had to go back and do it again, I would have just wrote a custom storage format. The amount of trouble that those databases caused was unbelievable; especially when you have more than one programmer working on the game.


#4994809 Create a Game Engine

Posted by ByteTroll on 28 October 2012 - 01:12 PM


i don't care hw many years it takes for me to complete a game or a game engine, i have already mentioned that i am juz 13 and the main reason for me is to learn things. Can anyone say me the best language to create games

There is no best language. The best one is the one that you can use -- e.g. some people would say, for example, "Java is crap", but the guy who made Minecraft was comfortable making games with Java, so he made a game using Java and got $200000000... There's no right or wrong choices in general, the answer depends on your personal situation.

Right now, the best language for you is one that's easy to learn. Common suggestions for easy to learn languages that you can easily make games with, are Python or C#, but there are also many others.
Eventually, I'd suggest that you learn C++, but I wouldn't recommend you start that until you're comfortable programming in other languages first, because it's a painful language to learn.

An Engine programmer will be proficient in many languages, so there's no need to rush straight to "the right language" immediately. I work as an engine programmer, and I regularly use C#, C++, Lua and batch. To begin with, you can make an engine using one language, but in the long run, you are going to be able to use many of them, so don't rush Posted Image

Also, keep in mind that talented people almost never build their magnum opus as their first work.
e.g.
* If you want to build space-shuttles, you don't start building one at 13 and work on it for a lifetime -- you start building toy rockets and motorbikes, then go to college, then get a job at NASA.
* If you want to build sky-scrapers, you play with lego, learn to draw, go to college, get a job designing houses, and build bigger and bigger things until you're finally working on giant towers.

Likewise, your first game engine should be very limited in scope. In order to not get carried away trying to make something too large, try and attach it to a particular game. As you take this journey of learning, there'll be points where it will be better to start your next step (mostly) from scratch, rather than trying to continue building atop what you've made so far. The foundations of an engine that you write today in 2012, aren't going to be strong enough to support development of engine code that you want to write in 2022. So, think of some achievable games that you want to make, and design your first engine around the requirements of those games only.
e.g. Before UDK there was the Unreal 3, which was created alongside Gears of War. Before that, there was Unreal 2.5, which was created for UT2004, before that was Unreal 2 for UT2003, before that was Unreal for Unreal.
Likewise, John Carmack made the Doom engine, then threw it out and made the Quake engine, then threw that out for Quake 2, then threw that out for Quake 3, then threw that out for Doom 3, etc...

I guess what I'm trying to say is, don't get caught up planning some project that will take you "I don't care how many years", because by then, you're going to be a much better programmer, and you'll have moved on past your initial code. e.g. John Carmack wouldn't want to use the Doom 1 engine code in Doom 4 -- he's thrown it out and written it again, because he's a different programmer now than he was then. It's great to have a big long-term goal (e.g. be a competent engine programmer), but you need to find the short-term stepping stones to getting there, and keep them in sight (e.g. build a 'Pong' engine, build a 'Mario' engine).


This is really solid advice. Nice job Hodgman!


#4989581 Virtual Coin Flip

Posted by ByteTroll on 12 October 2012 - 03:07 PM

Bytetroll got it almost right, although the else branch of the third result check is missing! That could lead to nasty bugs in your code (hey, why does it sometimes print 10 lines and sometimes just 9?), so fix it if you are going to use it. THAT is the reason why you shouldn't write programs copy-paste-style, if you have many same or almost same snippets in your program, you will at some point make a mistake when creating/editing it and the program will not work properly. So be wary of it and try to minimize it!

Also, it prints the result at start, so remove that line if you don't want to see that floating point number printed in your output.

If you cannot use the static keyword elsewhere than in main, you have to do either the ten ifs trick or use a class with recursive function (if anyone knows another approach, share your knowledge). That could look like this

import java.util.Random;
public class Coin {
  //Is the head upwards?
  protected boolean head;
  //Reference to random generator used.
  protected Random randomGenerator;

  //Init the coin to the init values
  Coin(boolean _head, Random _randomGenerator) {
	head = _head;
	randomGenerator = _randomGenerator;
  }
  //Flips the coin so it is heads 50% of time and tails 50% of time.
  void flip() {
	//notice that you can assign results of expressions to booleans
	head = randomGenerator.nextDouble() < 0.5;
  }

  //Prints the name of side that is upwards side
  void print() {
	if (head)
	  System.out.println("head");
	else
	  System.out.println("tail");
  }

  //Flips the coin repeat times and prints its upwards side after every flip
  void flipAndPrint(int repeat) {
	if ( repeat > 0) {
	  flip();
	  print();
	  flipAndPrint(repeat-1);
	}
  }

  //and some other functions if necessary (e.g. getter of the upwards side)

  //Flips a coin and prints the result ten times.
  public static void main (String[] args)
  {
	Random randomGenerator = new Random();
	//it doesn't matter if we choose heads or tails as the starting upwards side because it will be flipped anyway
	Coin coin = new Coin(true, randomGenerator);
	coin.flipAndPrint(10);
  }
}

Yeah, that's probably an overkill for now, but suppose that you would develop betting game software or something like that. Using ten ifs to flip ten coins would be rather unprofessional. (Of course you would be using for loops. But it is good practice in Java to split every non-simple task to a separate class - divide and conquer, so this applies a bit.)


Oh dear! That was a copy and paste fail. As ifthen stated... that is why you do not write programs copy and paste style. I wrote one block and then copy and pasted; missing one. Sorry about that one. Thank you for catching that ifthen!


#4989542 Virtual Coin Flip

Posted by ByteTroll on 12 October 2012 - 12:10 PM

I am not sure if you are still having issues with this assignment, but I got bored today and figured I would lend a final hand. I recoded my example in Java. I generally don't do peoples homework for them, but you have at least given it a shot. For future reference, however, I would look closely at what I have done and learn. Hope this helps.

import java.util.Random;
public class flip
{
	public static void main(String[] args)
	{
		//Since these values never get changed, it is good practice to make them
		//final.
		final double start = 0;
		final double end = 1;
	  
		//Declare this as an instantiation of Random, not a double.
		Random random = new Random();
	  
		//Set the initial value of the result variable.  Notice how I use the
		//"random" object.  Intead of using a double that has an initial value,
		//I generate a new value ("random.nextDouble()")
		double result = start + (random.nextDouble() * (end - start));
	  
		System.out.println(result);
	  
		//First result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.  Same thing
		//as the first call.  I use random to generate a new value.  If I didn't
		//and just used a double, the double variable would still have the same
		//value I set in the beginning.
		result = start + (random.nextDouble() * (end - start));
	  
		//Second result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Third result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Fourth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Fifth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Sixth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Seventh result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Eighth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Ninth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	  
		//Generate a new value and shove it in the result variable.
		result = start + (random.nextDouble() * (end - start));
	  
		//Tenth result check.
		if(result <= 0.5)
		{
			System.out.println("head");
		}
		else
		{
			System.out.println("tail");
		}
	}
}



#4989010 Virtual Coin Flip

Posted by ByteTroll on 11 October 2012 - 01:59 AM

You can also wrap every thing you are doing into a function and call it multiple times:

import java.util.Random;

public class flip {
	static Random random_generator;
	
	static void flip_once() {
		double random_number = random_generator.nextDouble();

		System.out.println(random_number);

		if (random_number < 0.5)
			System.out.println("head");
		else
			System.out.println("tail");
	}
	
	public static void main (String[] args) {
		random_generator = new Random();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
		flip_once();
	}
}


This is a much better way of doing it. I will second this.


#4989003 Virtual Coin Flip

Posted by ByteTroll on 11 October 2012 - 01:34 AM

i am trying to make the coin flip 10 times and display how much times heads and tails come out

A loop would be an ideal way, but seeing as you can't use them, why not call 10 "if" statements in a row?

I didn't have a computer available that had Java development stuff on it, so I whipped up a small demo using C# (which is close enough to get the point). I don't know why you can't use a loop, but this is a really poor way of doing it.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace flip_example
{
    class Program
    {
	    static void Main(string[] args)
	    {
		    Random random = new Random();
		    double start = 0;
		    double end = 1;
		    double result = start = (random.NextDouble() * (end - start));
		    Console.WriteLine(result.ToString());
		    //1
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //2
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //3
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //4
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //5
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //6
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //7
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //7
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //9
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //10
		    result = start = (random.NextDouble() * (end - start));
		    if (result < 0.5)
		    {
			    Console.WriteLine("Head");
		    }
		    else if (result > 0.5 && result < 1.0)
		    {
			    Console.WriteLine("Tail");
		    }
		    //Keep console window open.
		    Console.ReadLine();
	    }
    }
}



#4988734 I'd like to make a C++ game

Posted by ByteTroll on 10 October 2012 - 08:43 AM

I'd assume it's because C++ won't come with anything super-fancy

C++ is a programming language, not an API. API's are created with programming languages.

How do you turn your C++ .exe file look like a regular old program/game on Windows?

If you want to create a graphical GUI under Windows you are going to need to use the Win32 API. Here is a start http://www.winprog.org/tutorial/


#4984623 [SFML] I Finished Pong! I Can't Believe It!

Posted by ByteTroll on 27 September 2012 - 11:52 PM

Congrats!


PARTNERS