Jump to content
  • Advertisement

World69star

Member
  • Content Count

    36
  • Joined

  • Last visited

Community Reputation

121 Neutral

About World69star

  • Rank
    Member
  1. Well it looks like i found out the problem... it seems allegro doesn't like .jpegs one bit! The information on it i read said it supports all image formats, but apparently that it must not by default support jpegs. (maybe it needs another lib for that?) anyway i took my jpeg back into photoshop and turned it into a .pcx(an old photo format, that i know this supports being that allegro was an original dos library and that was the popular format back then.) And WAla..it worked.. Now does anyone know what formats allegro does support? and if there is a way to load jpegs?
  2. This code returning a 1 on the if(!image) statement for loading the image, it is driving me nuts, I thought maybe it a path problem using MSVC 2005 , and the fact that i am not using the default my docs folder, but in my l:\ drive. I put my jpg in every folder in the project and one above and it does the same thing everytime! The debugger is showing that none of the information is getting read to the image loader, it gives this for each set of values under iamge: - image 0xcccccccc {w=??? h=??? clip=??? ...} BITMAP * w CXX0030: Error: expression cannot be evaluated h CXX0030: Error: expression cannot be evaluated etc.... so it looks like either its not finding the image or something in the code is wrong. any help would be appreciated! /code //first program that I make to display a graphic image to the screen whala... #include "allegro.h" int main(void){ char *filename = "c:\m.jpg"; BITMAP *image; int ret; allegro_init(); install_keyboard(); set_color_depth(32); ret=set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480, 0, 0); if(ret != 0){ allegro_message(allegro_error); return 1; } //load the image file image = load_bitmap(filename, NULL); if(!image) { allegro_message("Error loading %s", filename); return 1; } //display the imagea blit(image, screen, 0,0,0,0,SCREEN_W, SCREEN_H); //done drating -delete bitmap from memory destroy_bitmap(image); //display videp mode information textprintf(screen, font, 0,0,10,"%d x % d" , SCREEN_W, SCREEN_H); //wait for keypress while(!keypressed()); //exit program allegro_exit(); return 0; } END_OF_MAIN() code/ Thanks in advance
  3. I just got visual studio 2005 prof free from college. I come from a 2 year java history using mainly netbeans, eclipse and command line compiler. I used to dabble in C++ but i always used dev++ or whatever it was called. 1. I installed the rather large platform sdk... I read this is neccessary for win32 applications, is that really the neccessary? as it uses a lot of space! Doesn't Visual studio 2005 prof come with all the header files etc.. you need for win32? If I don't need it is it ok to unistall it? 2. I installed the allegro binaries and tried to build this test code from a tutorial, everything has been double checked: /code #include <allegro.h> int main(int argc, char*argv[]) { allegro_init(); //init allegro install_keyboard(); //init keyboard set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); //sets graphics and screen res readkey(); //stall for input return 0; //return main } END_OF_MAIN() //Allegro specific code for every program must be called after main code/ these are the errors I get: 1>------ Build started: Project: AllegroTest, Configuration: Debug Win32 ------ 1>Compiling... 1>Test1.cpp 1>c:\program files\microsoft visual studio 8\vc\include\allegro\internal\alconfig.h(397) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned char *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\internal\alconfig.h(404) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned char *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(421) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned char *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(435) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned char *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(446) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned short *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(460) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned short *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(471) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned short *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(485) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned short *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(521) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned int *' of greater size 1>c:\program files\microsoft visual studio 8\vc\include\allegro\inline\draw.inl(535) : warning C4312: 'type cast' : conversion from 'unsigned int' to 'unsigned int *' of greater size 1>Compiling manifest to resources... 1>Linking... 1>Test1.obj : error LNK2019: unresolved external symbol __imp__readkey referenced in function "int __cdecl _mangled_main(int,char * * const)" (?_mangled_main@@YAHHQAPAD@Z) 1>Test1.obj : error LNK2019: unresolved external symbol __imp__set_gfx_mode referenced in function "int __cdecl _mangled_main(int,char * * const)" (?_mangled_main@@YAHHQAPAD@Z) 1>Test1.obj : error LNK2019: unresolved external symbol __imp__install_keyboard referenced in function "int __cdecl _mangled_main(int,char * * const)" (?_mangled_main@@YAHHQAPAD@Z) 1>Test1.obj : error LNK2019: unresolved external symbol __imp___install_allegro_version_check referenced in function "int __cdecl _mangled_main(int,char * * const)" (?_mangled_main@@YAHHQAPAD@Z) 1>Test1.obj : error LNK2019: unresolved external symbol __imp___WinMain referenced in function _WinMain@16 1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup 1>L:\C PLus Plus\VC8Projects\AllegroTest\AllegroTest\Debug\AllegroTest.exe : fatal error LNK1120: 6 unresolved externals 1>Build log was saved at "file://l:\C PLus Plus\VC8Projects\AllegroTest\AllegroTest\Debug\BuildLog.htm" 1>AllegroTest - 7 error(s), 10 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  4. I am making a Swing app in Java that can draw shapes depending on which shape is selected in the menu. The menu has different checkboxes. I have the checkboxes in a group and the line checkbox item is set to true at the start of the app. I also have an ItemListener to take care of the checkboxes, which then repaints the large JLabel, with the text that matches the menu item selected. I can get them all to work, but when I go back to check on line it does nothing. This is because i don't have the code: lType.setText("Lines"); there. When i put that code there it gives me an error(null point exception). unless i take out the setselected in the code, but then the background doesn't paint until i select one. Any help would be greatly appreciated. All i need help with is getting the checkboxes to all work and it to display the blue background and jLabel from start. Here is the code. code/ /** * * @author Rob */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MenuShaper extends JFrame implements ItemListener { private JMenuBar menuBar; private JPanel panel; private JPanel panel2; private JMenu menu1; private JCheckBoxMenuItem jbLine; private JCheckBoxMenuItem jbRect; private JCheckBoxMenuItem jbSquare; private JCheckBoxMenuItem jbCircle; private JCheckBoxMenuItem jbOval; public final JLabel lType; String dee = ""; public MenuShaper() { setSize(800,600); setTitle("The Shapes Project"); setDefaultCloseOperation(EXIT_ON_CLOSE); Container pane = getContentPane(); menuBar = new JMenuBar(); menu1 = new JMenu("Draw Tools"); panel = new JPanel(new FlowLayout()); //the menu checkboxes: ButtonGroup bgrp = new ButtonGroup(); jbLine = new JCheckBoxMenuItem("Lines"); jbRect = new JCheckBoxMenuItem("Rectangles"); jbSquare = new JCheckBoxMenuItem("Squares"); jbCircle = new JCheckBoxMenuItem("Circles"); jbOval = new JCheckBoxMenuItem("Ovals"); jbLine.addItemListener(this); jbRect.addItemListener(this); jbCircle.addItemListener(this); jbOval.addItemListener(this); jbSquare.addItemListener(this); bgrp.add(jbLine); bgrp.add(jbRect); bgrp.add(jbSquare); bgrp.add(jbCircle); bgrp.add(jbOval); jbLine.setSelected(true); menuBar.add(menu1); setJMenuBar(menuBar); menu1.add(jbLine); menu1.add(jbRect); menu1.add(jbSquare); menu1.add(jbCircle); menu1.add(jbOval); //add the drawing panel pArea pA = new pArea(); //pane.add(panel); panel.setBackground(Color.LIGHT_GRAY); panel2 = new JPanel(); pane.add(panel2); lType = new JLabel (dee,SwingConstants.CENTER); lType.setFont(new Font("Arial",Font.BOLD,40)); panel2.setLayout(new BorderLayout()); panel2.add(lType, BorderLayout.NORTH); panel2.setBackground(Color.CYAN); panel2.add(pA, BorderLayout.CENTER); setVisible(true); } //inner class pArea extends the component JPanel to be able to paint to it. public class pArea extends JPanel{ //paints onto the component public void paintComponent(Graphics g){ //turn the basic graphic object g into a supior Graphics 2d object by downcasting Graphics2D g2 = (Graphics2D)g; //following 2 lines of code turns on Accelerated Anti-Alaising to straighten out those rigid jaggies!!! g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawString("Temporary PlaceHolder Tester!!!" ,200,200); } } public void itemStateChanged(ItemEvent e) { if(e.getSource()==jbLine){ dee = "Lines"; } else if(e.getSource()==jbCircle){ dee="Circles"; //the lType code should go here but i get nuller lType.setText(dee);} else if(e.getSource()==jbRect){ dee="Rectangles"; lType.setText(dee); } else if(e.getSource()==jbSquare) { dee="Squares"; lType.setText(dee); } else if(e.getSource()==jbOval){ dee="Ovals"; lType.setText(dee); } } public void itemSelected(ItemEvent e){ } public static void main(String args[]){ MenuShaper mmenu = new MenuShaper(); } } //~ Formatted by Jindent --- http://www.jindent.com /code
  5. World69star

    Untitled

    I am making a Swing app in Java that can draw shapes depending on which shape is selected in the menu. The menu has different checkboxes. I have the checkboxes in a group and the line checkbox item is set to true at the start of the app. I also have an ItemListener to take care of the checkboxes, which then repaints the large JLabel, with the text that matches the menu item selected. I can get them all to work, but when I go back to check on line it does nothing. This is because i don't have the code: lType.setText("Lines"); there. When i put that code there it gives me an error(null point exception). unless i take out the setselected in the code, but then the background doesn't paint until i select one. Any help would be greatly appreciated. All i need help with is getting the checkboxes to all work and it to display the blue background and jLabel from start. Here is the code. code/ /* * MenuShaper.java * Project 3 chapeter 13 page 892 no.12 * Makes an JApplet with a menu bar to select different shapes to display on the screen by user mouse imputing the start * and end locations * * Created on October 21, 2007, 11:01 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ //~--- JDK imports ------------------------------------------------------------ /** * * @author Rob */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MenuShaper extends JFrame implements ItemListener { private JMenuBar menuBar; private JPanel panel; private JPanel panel2; private JMenu menu1; private JCheckBoxMenuItem jbLine; private JCheckBoxMenuItem jbRect; private JCheckBoxMenuItem jbSquare; private JCheckBoxMenuItem jbCircle; private JCheckBoxMenuItem jbOval; public final JLabel lType; String dee = ""; public MenuShaper() { setSize(800,600); setTitle("The Shapes Project"); setDefaultCloseOperation(EXIT_ON_CLOSE); Container pane = getContentPane(); menuBar = new JMenuBar(); menu1 = new JMenu("Draw Tools"); panel = new JPanel(new FlowLayout()); //the menu checkboxes: ButtonGroup bgrp = new ButtonGroup(); jbLine = new JCheckBoxMenuItem("Lines"); jbRect = new JCheckBoxMenuItem("Rectangles"); jbSquare = new JCheckBoxMenuItem("Squares"); jbCircle = new JCheckBoxMenuItem("Circles"); jbOval = new JCheckBoxMenuItem("Ovals"); jbLine.addItemListener(this); jbRect.addItemListener(this); jbCircle.addItemListener(this); jbOval.addItemListener(this); jbSquare.addItemListener(this); bgrp.add(jbLine); bgrp.add(jbRect); bgrp.add(jbSquare); bgrp.add(jbCircle); bgrp.add(jbOval); jbLine.setSelected(true); menuBar.add(menu1); setJMenuBar(menuBar); menu1.add(jbLine); menu1.add(jbRect); menu1.add(jbSquare); menu1.add(jbCircle); menu1.add(jbOval); //add the drawing panel pArea pA = new pArea(); //pane.add(panel); panel.setBackground(Color.LIGHT_GRAY); panel2 = new JPanel(); pane.add(panel2); lType = new JLabel (dee,SwingConstants.CENTER); lType.setFont(new Font("Arial",Font.BOLD,40)); panel2.setLayout(new BorderLayout()); panel2.add(lType, BorderLayout.NORTH); panel2.setBackground(Color.CYAN); panel2.add(pA, BorderLayout.CENTER); setVisible(true); } //inner class pArea extends the component JPanel to be able to paint to it. public class pArea extends JPanel{ //paints onto the component public void paintComponent(Graphics g){ //turn the basic graphic object g into a supior Graphics 2d object by downcasting Graphics2D g2 = (Graphics2D)g; //following 2 lines of code turns on Accelerated Anti-Alaising to straighten out those rigid jaggies!!! g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.drawString("Temporary PlaceHolder Tester!!!" ,200,200); } } public void itemStateChanged(ItemEvent e) { if(e.getSource()==jbLine){ dee = "Lines"; } else if(e.getSource()==jbCircle){ dee="Circles"; //the lType code should go here but i get nuller lType.setText(dee);} else if(e.getSource()==jbRect){ dee="Rectangles"; lType.setText(dee); } else if(e.getSource()==jbSquare) { dee="Squares"; lType.setText(dee); } else if(e.getSource()==jbOval){ dee="Ovals"; lType.setText(dee); } } public void itemSelected(ItemEvent e){ } public static void main(String args[]){ MenuShaper mmenu = new MenuShaper(); } } //~ Formatted by Jindent --- http://www.jindent.com /code
  6. World69star

    String Arrays problem. (JAVA)

    Thank you so much, that solved my problem, I knew their had to be some method to do this. Thanks again! Now I can continue!
  7. I am having a problem using String Arrays and can't figure out what i should do to get my desired result, the rest of my code is built, its this part that is holding me up. I have a list of names first name followed by last name. I need to get the wholle string and take the first part before the whitespace and place that in a String variable "FirstName", and place the String after the Whitespace in a String Variable "LastName". That way i can use them in my classes that i have already made. Here is an example: This is in Java code/ String FirstName; String LastName; String[]plist ={"Jane Flowes", "Luke Anderson", "Mary Smith", "Mark Flor", "John Goodall" }; FirstName=plist[0].???????????????? //should ="Jane" LastName=plist[0].????????????????? //should ="Flowers" /code The ??????? is what I can't figure out. Is there a sorting method or some code I could use to take the string before the whitespace for FirstName ,and do the same execpt after the whitespace for LastName. Once I have that, I can surround it in a loop and have it run through each one into my classes I made. Thanks in advanced for any help on this! (Wasn't sure where I should post this, as I put it in the java section too)
  8. I am having a problem using String Arrays and can't figure out what i should do to get my desired result, the rest of my code is built, its this part that is holding me up. I have a list of names first name followed by last name. I need to get the wholle string and take the first part before the whitespace and place that in a String variable "FirstName", and place the String after the Whitespace in a String Variable "LastName". That way i can use them in my classes that i have already made. Here is an example: code/ String FirstName; String LastName; String[]plist ={"Jane Flowes", "Luke Anderson", "Mary Smith", "Mark Flor", "John Goodall" }; FirstName=plist[0].???????????????? //should ="Jane" LastName=plist[0].????????????????? //should ="Flowers" /code The ??????? is what I can't figure out. Is there a sorting method or some code I could use to take the string before the whitespace for FirstName ,and do the same execpt after the whitespace for LastName. Once I have that, I can surround it in a loop and have it run through each one into my classes I made. Thanks in advanced for any help on this!
  9. I have a simple console based game I am trying to make (in java) and I can't figure out how to sort this array deck[] because it is a string array. I want to be able to sort and then print them in value order(greater cards after lesser cards in same suits) when they are dealt out in my main class. Can I sort the array based on the index number? If so how do you do it? OR do I cast it as a int, how can I do that with this array? Arrays always confuse me! I;d appreciate any help thanks; /code public class Cards { private String[] Deck = new String[52]; private boolean[] UsedCard = new boolean [52]; /** Creates a new instance of Cards */ public Cards() { Deck[0] = "Ace Hearts"; Deck[1] = "2 Hearts"; Deck[2] = "3 Hearts" ; Deck[3] = "4 Hearts"; Deck[4] = "5 Hearts"; Deck[5] = "6 Hearts"; Deck[6] = "7 Hearts"; Deck[7] = "8 Hearts"; Deck[8] = "9 Hearts"; Deck[9]= "10 Hearts"; Deck[10] = "Jack Hearts"; Deck[11] = "Queen Hearts"; Deck[12] = "King Hearts"; Deck[13] = "Ace Diamonds"; Deck[14] = "2 Diamonds"; Deck[15] = "3 Diamonds"; Deck[16] = "4 Diamonds"; Deck[17]= "5 Diamonds"; Deck[18]= "6 Diamonds"; Deck[19]= "7 Diamonds"; Deck[20]="8 Diamonds"; Deck[21]="9 Diamonds"; Deck[22]="10 Diamonds"; Deck[23]="Jack Diamonds"; Deck[24]="Queen Diamonds"; Deck[25]="King Diamonds"; Deck[26]="Ace Spades"; Deck[27]="2 Spades"; Deck[28]="3 Spades"; Deck[29]="4 Spades"; Deck[30]="5 Spades"; Deck[31]="6 Spades"; Deck[32]="7 Spades"; Deck[33]="8 Spades"; Deck[34]="9 Spades"; Deck[35]="10 Spades"; Deck[36]="Jack Spades"; Deck[37]="Queen Spades"; Deck[38]="King Spades"; Deck[39]="Ace Clubs"; Deck[40]="2 Clubs"; Deck[41]="3 Clubs"; Deck[42]="4 Clubs"; Deck[43]="5 Clubs"; Deck[44]="6 Clubs"; Deck[45]="7 Clubs"; Deck[46]="8 Clubs"; Deck[47]="9 Clubs"; Deck[48]="10 Clubs"; Deck[49]="Jack Clubs"; Deck[50]="Queen Clubs"; Deck[51]="King Clubs"; //init used cards to false for(int n=0; n <UsedCard.length;n++) { UsedCard[n]=false; System.out.println("" + UsedCard[n]+n); } } public String getCard() { int cardNumber; Boolean Flag = false; do { //generate a random number >0 <100 cardNumber = (int)(Math.round(Math.random()*100)); if(cardNumber <52) // if > 52 generates a new number if(UsedCard[cardNumber]==true) //test if card is allready used { Flag = false; }else // an unused card was found { UsedCard[cardNumber] = true; Flag= true; } else //random # is greater than 51 outside of the array { Flag= false; } } while(Flag==false); return Deck[cardNumber]; } public void newDeal() { for(int n=0; n<UsedCard.length;n++) { UsedCard[n]=false; } } } /code
  10. I have a simple console based game I am trying to make and I can't figure out how to sort this array deck[] because it is a string array. I want to be able to sort and then print them in order when they are dealt out in my main class. Can I sort the array based on the index number? If so how do you do it? OR do I cast it as a int, how can I do that with this array? Arrays always confuse me! I;d appreciate any help thanks; /code public class Cards { private String[] Deck = new String[52]; private boolean[] UsedCard = new boolean [52]; /** Creates a new instance of Cards */ public Cards() { Deck[0] = "Ace Hearts"; Deck[1] = "2 Hearts"; Deck[2] = "3 Hearts" ; Deck[3] = "4 Hearts"; Deck[4] = "5 Hearts"; Deck[5] = "6 Hearts"; Deck[6] = "7 Hearts"; Deck[7] = "8 Hearts"; Deck[8] = "9 Hearts"; Deck[9]= "10 Hearts"; Deck[10] = "Jack Hearts"; Deck[11] = "Queen Hearts"; Deck[12] = "King Hearts"; Deck[13] = "Ace Diamonds"; Deck[14] = "2 Diamonds"; Deck[15] = "3 Diamonds"; Deck[16] = "4 Diamonds"; Deck[17]= "5 Diamonds"; Deck[18]= "6 Diamonds"; Deck[19]= "7 Diamonds"; Deck[20]="8 Diamonds"; Deck[21]="9 Diamonds"; Deck[22]="10 Diamonds"; Deck[23]="Jack Diamonds"; Deck[24]="Queen Diamonds"; Deck[25]="King Diamonds"; Deck[26]="Ace Spades"; Deck[27]="2 Spades"; Deck[28]="3 Spades"; Deck[29]="4 Spades"; Deck[30]="5 Spades"; Deck[31]="6 Spades"; Deck[32]="7 Spades"; Deck[33]="8 Spades"; Deck[34]="9 Spades"; Deck[35]="10 Spades"; Deck[36]="Jack Spades"; Deck[37]="Queen Spades"; Deck[38]="King Spades"; Deck[39]="Ace Clubs"; Deck[40]="2 Clubs"; Deck[41]="3 Clubs"; Deck[42]="4 Clubs"; Deck[43]="5 Clubs"; Deck[44]="6 Clubs"; Deck[45]="7 Clubs"; Deck[46]="8 Clubs"; Deck[47]="9 Clubs"; Deck[48]="10 Clubs"; Deck[49]="Jack Clubs"; Deck[50]="Queen Clubs"; Deck[51]="King Clubs"; //init used cards to false for(int n=0; n <UsedCard.length;n++) { UsedCard[n]=false; System.out.println("" + UsedCard[n]+n); } } public String getCard() { int cardNumber; Boolean Flag = false; do { //generate a random number >0 <100 cardNumber = (int)(Math.round(Math.random()*100)); if(cardNumber <52) // if > 52 generates a new number if(UsedCard[cardNumber]==true) //test if card is allready used { Flag = false; }else // an unused card was found { UsedCard[cardNumber] = true; Flag= true; } else //random # is greater than 51 outside of the array { Flag= false; } } while(Flag==false); return Deck[cardNumber]; } public void newDeal() { for(int n=0; n<UsedCard.length;n++) { UsedCard[n]=false; } } } /code
  11. World69star

    C++ Workshop - Introduction

    I think this is agreat idea! I don't have that book, but would be glad to get it to learn more from this! I know Basic C++ and Java and learned programming in general on QBASiC back in the early 90's(high school) , but I still need to learn more C++ before I move on to an API! I am sketchy with pointers and arrays. Not to mention the templates. I still don't understand "Pass by reference" or "by Value" Also don't know the difference betwee "the heap and the stack" So yeah this sounds promissing! To the dude who objection of using C++, what langugae would you choose? I stopped learning java and c# becasue of the lack of onformation and gaming/multimedia relavent stuff. I like to know how and why things work. Java/and .net seem too high level and just give you premade classes and fuctions allready made to work with, mainly related to database and Enterprise business apps. Thats great for someone wanting Rapid app Developement(RAD), but for games, no. C++ has been the standard of the industry for a reason! Why would developers want to "Stay away from it?" Learning C++ always feels right to me! and their is hundreds of libraries out there related to games! :)
  12. World69star

    Help with random!

    Hey thanks for the help and advice! I took your solution and added the srand() to my program and redid the game loop. PLus added a bunch of spit and polish with more options and some conditional replies depending on your guess. It works great in Bloodshed DEv-C++, but I tried the same exact program in Visual Studio 8 and it won't compile and I get an error about 'time' identifier not found. What does 'time' represent and how come it doesn't work in VS8, but fine in DEV c++? The code peice it's refering to is: srand( time(NULL) ); also here is my finished game of Higher/Lower: The Psychic Tester! #include <iostream> #include <string> #define getrandom(min, max) min+(rand()%(max-min+1)) using namespace std; int main() { system("COLOR 1f"); cout << " Welcome to an amazing game of luck:" <<endl; cout << endl; cout << " HIGHER OR LOWER? " << endl; cout <<endl; cout<< " The Paranormal ESP tester:"<<endl; cout<<endl; cout <<" Are You Psychic or just a Retard? "<<endl; cout <<" We Shall soon see!" <<endl; cout <<endl; cout << ".......Directions: input a number and the computer will tell you \n"; cout<<endl; cout<< "if the number you guess is:"<<endl; cout<<" ------------Higher or Lower!____________"<<endl; cout<<endl; cout <<"--------->The idea is to guess the number<----------" << endl; cout <<endl; cout<<endl; cout << "...................Can you do it?................" << endl; system("PAUSE"); system("CLS"); cout<<endl; cout << "Here We go! ARE YOU READY? DO IT!!!!" << endl; bool loopy = true; unsigned int numbro; srand( time(NULL) ); numbro=getrandom(1,100); unsigned int guess; unsigned int count; count=0; int dowap=0; //game loop do{ cout << "Enter a number from 1 to 100" << endl; cin>>guess; cout<<endl; if(guess > 0 && guess <101 ){ count++; if(guess < numbro) { cout << "Your Number is LOWER!" <<endl; }else if(guess > numbro) { cout << "Your Number is HIGHER!" <<endl; }else if(guess==numbro){ cout<<"\n"; cout <<"You got it right! You Win!"<<endl; cout <<"It only took you : " << count <<" guesses!"<<endl; cout<<"\n"; //counterpart: if(count>25){ cout<<"Your just plain retarted!!"<<endl; }else if(count > 10 && count <= 25){ cout<<"You are an average guesser and have no ESP! "<<endl; cout<<"Better luck next time!"<<endl; }else if(count > 5 && count <= 10){ cout <<"Your pretty good, but not a psychic!"<<endl; }else if(count >= 2 && count <= 5){ cout<< "You have some ESP! against a computer! Way to go!!!"<<endl; }else if(count==1) { cout<<"YOU are a Psychic Genius! You got it on the first try!! "<<endl; }else {cout<<"What????????????"<<endl; } //repeater string aga; cout<<endl; if(dowap>0){cout<<"CHEAT MODE WAS ENABLED!"<<endl; cout<<"so you are not Psychic just a CHEATER!"<<endl; } cout<<endl; count=0; cout<<"Do you want to try again?"<<endl; cout<<"enter y for yes, n for no"<<endl; cin>>aga; numbro=getrandom(1,100); if(aga=="n"|| aga=="N"){ loopy=false; }else if(aga=="y"||aga=="Y"){ dowap=0; loopy==true; }else{ cout<<"Your really retarted!!"<<endl; cout<<"Too retarted for this game!!"<<endl; loopy=false; } } }else {cout << "Number is invalid: enter a number between 1 and 100, Try Again!"<<numbro<<"\n hehehe...you found the cheat!"<<endl; if(guess>100){dowap++;} cout<<endl; } } while(loopy); system("PAUSE"); } Thanks a lot for the help! This forum community never ceases to amaze me!
  13. World69star

    Help with random!

    Here's a simple high/Lower game: #include <iostream> #define getrandom(min, max) ((rand()%(int)(((max) + 1)-(min)))+ (min)) using namespace std; int main() { system("COLOR 1f"); cout << " Welcome to an amazing game of luck:" <<endl; cout << endl; cout << " HIGH OR LOW? " << endl; cout <<endl; cout <<endl; cout << ".......Directions: input a number and the computer will tell you higher or lower.\n"; cout << ".......The idea is to guess the number......." << endl; cout << "...........Can you do it?................" << endl; system("PAUSE"); system("CLS"); system("COLOR 04"); cout << "Here We go! ARE YOU READY? DO IT!!!!" << endl; int what = 0; int loopy = 1; unsigned int numbro; numbro=getrandom(1,100); unsigned int guess; //game loop while(loopy){ cout << "Enter a number from 1 to 100" << endl; cin>>guess; if(guess < numbro){ cout <<"LOWER!"<<endl; what=0; } if(guess > numbro) { cout << "HIGHER!" <<endl; what=0; } if(guess==numbro)what=1; if(what==1)loopy=0; } cout <<"You got it right! You Win!"; system("PAUSE"); } It compiles and runs, the higher lower part doesn't work right. It will say lower on numbers lower then 50 and higher for over 50. PLease some advice thnaks.
  14. World69star

    Windows Console, why is it so crippled?

    Thanks guys! That helps a lot I'll have to mess with it! I always thought it was emulated DOS, wasn't it in windows 95/98?
  15. Why can't you change the text color, or background in the windows console, or plot pixels or make DOS type menu driven apps? I remeber back in the day DOS being able to support that. The Qbasic interpreter I learned on in High School back in early 90's on my 386, it had it, was menu driven, and had colored text. So did Edit.exe I understand the DOS console window in win XP is emulated and cut down, but why? Does it have to be? We live in an age with 3ghz pc's and we can't emulate DOS to it's full implementation? Is ther a way to make a DOS Console have Colored text and background? Has anyone made a better emulated version? How hard would it be and could it be possible to programm a new console or add to it with C++ or would Assembly be needed? Sorry so many questions, it just has been buggin me for a while, I would love to be able to implement a color console (with pixel ploting capabilities...Ok maybe now I'm asking for too much, but Color text/Background shouldn't be too much)
  • 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!