Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 ... 19 20 [21] 22 23 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 95880 times)

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #300 on: July 31, 2010, 09:41:02 am »

Minecraft? I would say the completely arbitrary number of 10 years.

It has 3D graphics with transparency and textures(not very hard), world generation(somewhat hard), and probably graphical optimization(VERY HARD), plus it is a 1st or 3rd person 3D game(Also very hard). And then the networking(very hard, too).

It is basically a full 3D FPS engine, only with collision reduced to large voxels. In Java. With multiplayer. And dynamic levels, too.
Logged
Eh?
Eh!

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #301 on: July 31, 2010, 10:45:01 am »

Yeah, I'm going to say 10 years as well.
The 3D and transparencies aren't that difficult, but everything else mentioned is.

I have around a year of programming experience, and I made Cloud Scream.
That has tile based physics, digging, building, and that sort of thing,
 but you can tell how terribly un-optimized it is, and the controls could kill the faint-hearted.
The hardest things to do were making it 3D, adding textures, adding sounds, and adding text overlays.
Making a functional save system is difficult too, as in I have never completed one before.

You have to start somewhere...

I recommend writing an interactive fiction game
 (in the language you want to be proficient in)
 or a 2D rogue-like in ASCII.

Take my advice as a passing fancy compared to these fellows though.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #302 on: July 31, 2010, 08:48:28 pm »

I had a small/vague question. How long does it take to learn how to make things like Minecraft?
I can't speak for Java like Minecraft was written in, but I personally have been learning C++ and DirectX. I started ~4 years ago, although much of that was wasted due to not having any actual school-learning until just this year. At this point I am able to make simple 3D games, but I haven't even started looking into learning how to do multiplayer. I wouldn't say 10 years though, probably closer to 4 or 5 if you were a jobless student with plenty of spare time and who didn't squader said spare time playing Dwarf Fortress. Less if you are a student in a relevant field.

Although more than anything else when talking about these time scales, it depends how insane/dedicated you are feeling at the time. You could probably go 16 hours a day, 7 days a week and learn it all in a few months, but that isn't something which I would recommend.

But as Orange said:
Quote
Take my advice as a passing fancy compared to these fellows though.
« Last Edit: July 31, 2010, 08:56:05 pm by alway »
Logged

eerr

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #303 on: August 01, 2010, 06:39:39 am »

I'm just sayin, going straight for a massive program as your primary goal is a bit absurd, if you have no experiance.
Logged

Dakorma

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #304 on: August 01, 2010, 09:37:58 am »

I'm just sayin, going straight for a massive program as your primary goal is a bit absurd, if you have no experiance.
It's more of my goal being that in the long term, along with procedural generation in the short term.
Logged

IHateOutside

  • Bay Watcher
  • Fire safety is for wimps.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #305 on: August 01, 2010, 01:47:04 pm »

Hey everyone!

I figured this was the right place to put this. I've just finished creating a random number generator, mostly from my own (limited) knowledge. Just wanted to know what more experienced programmers thought of my work.

Code: [Select]
//This program creates a random number and tasks the players to guess it.
//You can set the maximum value of the number you must guess using MAX_VALUE.
//Thats basically the difficulty setting.

#include "stdafx.h"
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int const MAX_VALUE = 10;

int randomNumber()
{
 srand(time(0));
 return rand() % MAX_VALUE + 1;
}


int main()
{
int numberToGuess = randomNumber();
int playerGuess = 0;
int numberOfGuesses=0;

do
{
cout << "Enter your guess. The number is between 1 and " << MAX_VALUE << endl;
cin >> playerGuess;
cout << endl;
numberOfGuesses++;
if (numberToGuess > playerGuess)
{
cout << "Higher!" << endl;
}

else if (numberToGuess < playerGuess)
{
cout << "Lower!" << endl;
}

else if (numberToGuess == playerGuess)
{
cout << "You got it! Good job!" << endl;
cout << "You managed it in..." << numberOfGuesses;

if (numberOfGuesses == 1)
{
cout << " guess\n";
}
else
{
cout << " guesses\n";
}

break;
}
}
while (playerGuess != numberToGuess);

return 0;
}
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #306 on: August 01, 2010, 02:34:46 pm »

Hey everyone!

I figured this was the right place to put this. I've just finished creating a random number generator, mostly from my own (limited) knowledge. Just wanted to know what more experienced programmers thought of my work.

Code: [Select]
//This program creates a random number and tasks the players to guess it.
//You can set the maximum value of the number you must guess using MAX_VALUE.
//Thats basically the difficulty setting.

#include "stdafx.h"
#include <cstdlib>
#include <ctime>
#include <iostream>

using namespace std;

int const MAX_VALUE = 10;

int randomNumber()
{
  //srand moved to beginning of program
 return rand() % MAX_VALUE + 1;
}


int main()
{
             srand(time(0));
int numberToGuess = randomNumber();
int playerGuess = 0;
int numberOfGuesses=0;

do
{
cout << "Enter your guess. The number is between 1 and " << MAX_VALUE << endl;
cin >> playerGuess;
cout << endl;
numberOfGuesses++;
if (numberToGuess > playerGuess)
{
cout << "Higher!" << endl;
}

else if (numberToGuess < playerGuess)
{
cout << "Lower!" << endl;
}

else if (numberToGuess == playerGuess)
{
cout << "You got it! Good job!" << endl;
cout << "You managed it in..." << numberOfGuesses;

if (numberOfGuesses == 1)
{
cout << " guess\n";
}
else
{
cout << " guesses\n";
}

break;
}
}
while (playerGuess != numberToGuess);

return 0;
}
I remember making that mistake... The srand() line only has to be done once. Do that at the start of the program rather than in the function, since otherwise getting a random number within the same second as the previous one will result in the same number. Srand is a random seed. Given the same seed, the same set of numbers will be generated. Time, as you have done, is usually used as the seed number, since it ensures the seed will be different each time the program runs. After being seeded once, you don't need to seed it again. In that specific code, it probably won't matter. But if you plan on using that random number generation for something which calls more than a single random number, it is best to just seed at the start, then just call "return rand() % MAX_VALUE + 1;" in the function. (See modifications in quoted code)There may be other errors, but I'm not seeing them.

That said, depending on what you are running that code through, you may want a system("pause"); in there at the end to keep it from immediately closing before the player is able to see the "You Win" message.
« Last Edit: August 01, 2010, 02:47:33 pm by alway »
Logged

IHateOutside

  • Bay Watcher
  • Fire safety is for wimps.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #307 on: August 01, 2010, 02:46:46 pm »

Thanks for the little tip. I had started that a while ago and floundered on the do and if statements, then earlier today I was reading a pdf C++ book and with its help managed to get it to work. I'm quite pleased at myself and will probably read more of the book as its focused on game programming and each chapter has a game to program at the end of it.
Logged

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #308 on: August 01, 2010, 02:58:42 pm »

One thing some books neglect is the system() commands, I suggest looking those up since they add in a bit more fun possibilities than normal. system("pause") is very useful, since it gives you a prompt to press enter to continue, there are also color commands (at least on my system, it may vary from one OS to another IIRC) which allow you to change the color of the background and text* in the command prompt window. Nothing says "HEY, YOU ARE BEING ATTACKED" in a text rpg better than all the text turning bright red. Type in "help" in the command prompt to see a list of those.

*To specify, you can't specify which text turns color, it's an all or nothing deal. So you can't have one red line, one blue line, and four white lines.
« Last Edit: August 01, 2010, 03:00:58 pm by alway »
Logged

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #309 on: August 01, 2010, 03:28:01 pm »

You should never use system() if an alternative exists. If you are using system() to do very standardized things like change text color, you are doing it wrong. Emit terminal-specific ANSI codes or use a curses library.
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

IHateOutside

  • Bay Watcher
  • Fire safety is for wimps.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #310 on: August 01, 2010, 04:22:59 pm »

The IDE I use already adds a pause at the end of a program that says 'Press any key to continue'.
Logged

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #311 on: August 01, 2010, 06:26:15 pm »

The IDE I use already adds a pause at the end of a program that says 'Press any key to continue'.

Most only do that for debug versions, or only for executables in the debug directory.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #312 on: August 01, 2010, 06:27:20 pm »

You can do that too:

Quote from: run.bat
programname.exe [args]
pause

system("pause") is, although far from the best way, a decent method of pausing the program that should not be used an any advanced project or anything you intend to share.

Try this instead:
Code: [Select]
#include <stdio.h>
void pause()
{
    printf("Press Enter to continue...\n");
    fgetc(stdin);
}

Unfortunately, stdio.h does not have anything that can accept a single keypress, unlike system("pause") or some nonstandard libraries like conio.h's getch().
Logged
Eh?
Eh!

Dakorma

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #313 on: August 01, 2010, 07:07:19 pm »

I'd like to add some links to this threads first post.

Python
-How to Think Like a Computer Scientist:Python
-Dive into Python

Ruby
-Try Ruby Seriously right in your browser, it goes over the basic syntax for Ruby as well as some basic commands from a webapp in your browser.
-pickaxe for ruby 1.6, still very relevant
-Learn to Program

LOGO
-How to Think.
Logged

IHateOutside

  • Bay Watcher
  • Fire safety is for wimps.
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #314 on: August 01, 2010, 07:13:13 pm »

The IDE I use already adds a pause at the end of a program that says 'Press any key to continue'.

Most only do that for debug versions, or only for executables in the debug directory.

My bad, this is correct. I recall seeing something along the lines of cin.get() being used to pause as well.

Adding qwerty's code at the bottom of mine doesn't seem to do anything.
« Last Edit: August 01, 2010, 07:17:27 pm by IHateOutside »
Logged
Pages: 1 ... 19 20 [21] 22 23 ... 78