Jump to content

Learning C++

- - - - -

  • Please log in to reply
3 replies to this topic

#1
robbert22

robbert22

    Newbie

  • Members
  • Pip
  • 1 posts
Hello.

I'm learning C++ through books and tutorials on the web like cplusplus.com and cprogramming.com, the book I'm currently using also is "C++ Primer plus 5th edition".

I'm going through the concepts in the language, for example, variables, control structures, functions,arrays, classses etc but the problem is, i just don't know how to write my own code exactly.
like I'm learning these concepts, but i don't know how to apply them and formulate my own program.

Like the only way i would know how to do something is by copying the code from a book or website but i wouldn't know exactly how to write my own program.

Why is this? when do you think i will be able to program something with my own code. My main intention is to do game programming and desktop.

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Well, you could start with simple text games (hangman, tic-tac-toe, 4-in-a-row, bulls'n'cows). Maybe a phonebook, ATM machine or something like that. And then you can improve these things (add new options, make GUI).
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
Yes, something like a phone book may seem pointless and take many days, but it teaches invaluable skills that can be applied to almost any subject regarding data and arrays (as games), hangman can teach quite a bit about generation of random strings, working with file handles to get the string list and AI if you want a computer to try to solve it on their own (with random letters)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#4
Muted

Muted

    Learning Programmer

  • Members
  • PipPipPip
  • 86 posts

robbert22 said:

Why is this? when do you think i will be able to program something with my own code. My main intention is to do game programming and desktop.
I think this is because a lack of experience and practice! As Nullw0rm and Flying Dutchman suggested: Write your own programs.
They may be text-based, and deceptively "simple," but trust me: If ASCII games ("rogue-like") were simple, people wouldn't have made a lot of money from them!

I agree with Flying Dutchman, you should try writing simple text-based games right now. Here, I'll even conjure up a list of some potentially fun games:

  • Guessing game! Write a two-player game. Have the first player input a number, and the second player guess that number (1-100, he has 15 guesses!).
  • Nuclear Doggy. Write a program that asks a user for his favorite number! After he inputs it, randomly generate an output saying how many dogs have died, and why.
  • Stranger danger. Write a program that asks a user for his first, and last name, then informs him that that's not a safe idea (something like, "Dear <First name Last name>, giving this information out freely on a computer isn't the best of ideas (for your own safety!)."
  • Evil cats. Write a program that asks how many cats somebody would like to adopt. If it's 0, tell them they've won "1 free kitty!" If it's greater than 1, display a brief (comical) story of how they cats have conspired against you, and taken over your household.
  • Dragon slayer. Write a fun single player game where you can pick between 1-3 pre-made Dragons! Dragons will be represented by a structure ("struct" keyword), and contain: A name, an age, and damage. Create a really! Simple fighting function, where it randomly sets you up against enemy Dragons (instantiated from the "Dragon struct" object).
  • Tic-Tac-Toe! Write a simple Tic-Tac-Toe game where you can play against the computer, another player, or watch the computer play against himself! :c-cool:

Hopefully these ideas will inspire you to create more fun games (and programs) on your own with C++! :c-grin:
“You may be disappointed if you fail, but you are doomed if you don't try.”
- Beverly Sills




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users