Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 86,242 C++ Programmers. There are 2,258 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a C++ Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Need help with C++ Console Application

6 Pages V  1 2 3 > »   
Reply to this topicStart new topic

Need help with C++ Console Application, Someone wants to work with me?

Rating  5
Codegamer
post 4 May, 2008 - 04:01 AM
Post #1


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 42



Hi! I'm using DEV-C++ and need som help or something...

I've some questions about C++ and Dev-C++ here they are:

Can you put music or pictures in dev-c++ when you making something in Console Application?
It's something in my code i should chance?
How far can you go with Dev-C++ when your're making a game?
Should i chance C++ if i want to make a game?
It's someone who wants to work with me? My brother have an company there we make games so dreams can come true cool.gif
What do you think of my code?


I've only been working with C++ in 4 days so I'm a noob.
Sorry for my english I''m from Sweden and I'm only 13 years old^^


Here is my code:

cpp


/*Name: WOP BETA 1.2
Copyright: W.O.P LTD All Rights Reserved
Author: Tommie Larsson
Date: 04-05-08
Description: A beta of the game and console W.O.P.
*/


#include <iostream>
#include <string>
#include <vector>
#include <windows.h>
#include <cstdlib>
#include <ctime>


using namespace std;

int main ()
{

cout << " " << endl;

cout << "\tWOP requesting login\n";
int security = 0;

string username;
cout << "\nUsername: ";
cin >> username;

string password;
cout << "Password: ";
cin >> password;

if (username == "Gamepower" && password == "j6wfmdd5")
{
cout << "\nWelcome Gamepower to WOP.";
security = 5;
}

if (username == "Unrealgamer" && password == "Unrealgamer")
{
cout << "\nWelcome Unrealgamer (Jens) to WOP.";
security = 5;
}

if (username == "quest" && password == "guest")
{


cout << "\nWelcome guest.";
security = 1;
}

if (!security)
cout << "\nYour login failed.";
else // <-- ADD ME
{

cout << " " << endl;
cout << " " << endl;
cout << " " << endl;

cout << "Please choose difficulty level:" << endl;

cout << " " << endl;
cout << " " << endl;

cout << "Difficulty Levels\n\n";
cout << "1 - Easy\n";
cout << "2 - Normal\n";
cout << "3 - Hard\n\n";

int choice;
cout << "Choice: ";
cin >> choice;

switch (choice)
{

case 1:
cout << " " << endl;
cout << "Easy? You're a real noob!\n";
break;

case 2:
cout << " " << endl;
cout << "Normal of course!\n";
break;

case 3:
cout << " " << endl;
cout << "God luck!\n";
break;

}

cout << " " << endl;
cout << "This is just a beta of a game so we go directly to" << endl;
cout << "when you just have died in the game^^" << endl;
cout << " " << endl;

cout << " " << endl;
cout << "Gameover! " << endl;
cout << " " << endl;
}

char again = 'y';
while (again == 'y')
{

cout << "\nDo you want to play again? (y/n): ";
cin >> again;
}

cout << "\nOkay, logging out!";


std::cout << "Press the key to exit";
std::cin.ignore(std::cin.rdbuf()->in_avail() + 1);


return 0;
}




//Codegamer

This post has been edited by Codegamer: 4 May, 2008 - 12:01 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Codegamer
post 4 May, 2008 - 04:20 AM
Post #2


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 42

cout <<"Hello! someone want to reply this?" << endl; blink.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Cerolobo
post 4 May, 2008 - 05:45 AM
Post #3


D.I.C Head

**
Joined: 5 Apr, 2008
Posts: 151

Since you are using windows, the easiest way to play to sound, is to use PlaySound().

You'll have to add -lwinmm to the command line compilation options though, which I don't know how to do through the Dev C++ GUI.

To draw pictures, its a lot more complicated. If you just do ASCII art, you can store the images and plan text, and just print them. If you actually want to do real pictures (bitmaps for example), you'll have to basically write the code to read the image format, and then call SetPixel(). Again, if you use actual image files, you'll be getting into a lot more work.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KYA
post 4 May, 2008 - 05:47 AM
Post #4


DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC

Group Icon
Joined: 14 Sep, 2007
Posts: 1,318

QUOTE(Codegamer @ 4 May, 2008 - 05:01 AM) *

Hi! I'm using DEV-C++ and need som help or something...

I've some questions about C++ and Dev-C++ here they are:

1. Can you put music or pictures in dev-c++ when you making something in Console Application?
2. It's something in my code i should chance?
3. How far can you go with Dev-C++ when your're making a game?
4. Should i chance C++ if i want to make a game?


1. No. AFAIK You'd have to make a win32 app to utilize graphics or sound
2. Yes, you have to code in graphic and sound support
3. All the way (you'll have a hello f a time linking directX stuff if you use that library though, thats why I eventually bought a copy of visual studio)
4. yes, good language, commercials apps use it

User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Codegamer
post 4 May, 2008 - 06:27 AM
Post #5


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 42

I tested ASCII art and it worked great but i want real pictures and music but i still don't get it with PlaySound()....
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KYA
post 4 May, 2008 - 06:29 AM
Post #6


DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC

Group Icon
Joined: 14 Sep, 2007
Posts: 1,318

Even if its possible, the point of a console app is to not have bells and whistles. Build a GUI if you want to go that route.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Cerolobo
post 4 May, 2008 - 06:34 AM
Post #7


D.I.C Head

**
Joined: 5 Apr, 2008
Posts: 151

PlaySound() can play a .wav file, which can contain "real music". As for the images, as KYA suggested, you might as well start working on a GUI interface.

Personally, I think they will be to much trouble to implement as of right now. With only 4 days of experience, you'll be far better off learning the basics of C++ or just C, then trying to jump into a fully functional game.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Codegamer
post 4 May, 2008 - 06:41 AM
Post #8


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 42

Do i only need to put in PlaySound()? And how does it know what file i want to play?
If i chance to GUI do i ne to start over ?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Cerolobo
post 4 May, 2008 - 06:47 AM
Post #9


D.I.C Head

**
Joined: 5 Apr, 2008
Posts: 151

the documentation for PlaySound() is here
http://msdn.microsoft.com/en-us/library/ms712879.aspx

Bascially, to use it, you have to add
#include <windows.h>

and then add

PlaySound(<.WAV FILE TO PLAY>, 0, SND_FILENAME);

where ever you want sound to play.

Once that is done, you have to add -lwinmm to your linker options, which I don't know how to do through the Dev C++ GUI.


As for the GUI, yes, you'll have to start over. Not to mention that you'll have to do a lot of work to learn the Windows API (namely, GDI+).
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

KYA
post 4 May, 2008 - 06:54 AM
Post #10


DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC DIC

Group Icon
Joined: 14 Sep, 2007
Posts: 1,318

Boilerplate WinAPI is a pain is the butt. I still don't fully know it all sad.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Cerolobo
post 4 May, 2008 - 06:57 AM
Post #11


D.I.C Head

**
Joined: 5 Apr, 2008
Posts: 151

QUOTE(KYA @ 4 May, 2008 - 06:54 AM) *

Boilerplate WinAPI is a pain is the butt. I still don't fully know it all sad.gif

Well, you can't really know the Windows API. It's just to massive... Thats where MSDN comes in handy.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Codegamer
post 4 May, 2008 - 07:18 AM
Post #12


New D.I.C Head

*
Joined: 4 May, 2008
Posts: 42

I've only one problem now! The login thing when you don't give it the right name and password it says Login Failed but when it comes i want it to exit becuase choose levels comes after it says that and i don't want that. I tried to chance that and i worked but when you put the right name and password i closes!
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

6 Pages V  1 2 3 > » 
Reply to this topicStart new topic
Time is now: 5/16/08 08:21AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month