Jump to content
  • Advertisement

AstralAaroN

Member
  • Content Count

    33
  • Joined

  • Last visited

Community Reputation

124 Neutral

About AstralAaroN

  • Rank
    Member
  1. AstralAaroN

    C#, C++

    My question is for both c# and c++,just wondering if any database can be used with these languages including MySQL and also which would you recommend and why? + Do you know where I can find any tutorials covering a basic connect to database hello world lesson? preferably c# but either will do.
  2. AstralAaroN

    Extreme Newbie here - hello world :)

    Quote:Original post by jpetrie Quote: Just a tip: B Buying a book and using it, is alot better than reading stuff online. This is because you'll learn bad coding guidelines form online stuff. I would get a "for dummies" book if I was you :) . This is pretty bad advice. It isn't always the case that information on the internet is incorrect or misleading, sometimes it's quite good. Likewise, it's not always the case that a book is better -- I've seen quite a few books, "For Dummies" books included, that are complete crap. A beginner is probably not experienced enough to make the determination regarding the quality of a learning resource effectively. As such it is preferable to avoid blanket and vague "recommendations" like this, because they don't tend to get anybody anywhere. I agree with jpetrie, this is not the first language I've studied. I've always found programming books to be confusing. They throw all these concepts at you without giving any practical example. I learn best in these discussion forums. trust me I am learning a LOT. [/qoute] (i've been trying to post the past day here, anyone else have problems with this website just stalling?) Quote:oler1s sorry I took your post the wrong way.
  3. AstralAaroN

    Extreme Newbie here - hello world :)

    Quote:Original post by oler1s About your posts: You should form new threads when you have a new line of questions. You're just tacking on and on to this thread like this is your personal help thread. Hopefully, a mod will split off this portion of the thread and give it a decent thread title ("Extreme newbie" is not a good thread title). o1er1s I disagree with starting a new topic for every question I have, what sense does that make? other forums I've used for programming prefer things be kept in 1 thread to not spam the forum. I don't see your logic here. It was the first time I used classes, obviously I am a little confused about them... In your post it seems like you are offended by me, just pass my thread up next time. no need for negativity, just relax. Overall your post was slightly informational, thanks.
  4. AstralAaroN

    Extreme Newbie here - hello world :)

    Hi I got really busy the past few days and the C++ marathon was on hold but is restarting right now :) Before I got busy, I was learning all kinds of concepts and trying to understand them. This post is mainly about classes. I created this little game "Coin Toss Casino" and tried to make use of classes. Curious to have someone look through what I've done and point out anything I am doing right, or wrong. am I using member functions effectively? here's the code: #include <iostream> #include <ctime> #include <string> //streak, a game that generates 1 of 2 numbers and lets a player bet on the result // the longer your streak is the more points you receive. void playGame(); bool gameOver = false; class Player { public: Player() : money(200), streak(0), total(0), name("Player") {} long long money; int streak; int total; std::string name; }; Player One; //declair a player class Machine { public: void generate(int bet, int guess) { time_t t; time(&t); srand(t); int res = (rand() % 2); outCome(bet,guess,res); } void takeBet(int bet, int guess) { One.total;// = One to; generate(bet, guess); } void outCome(int bet, int guess, int iRand) { if(iRand == guess) { int prize; std::cout << "The Number IS !: " << iRand << std::endl; One.streak = (One.streak + 1); if (One.streak == 0 || One.streak == 1) { prize = bet; int payBack = (bet + bet); std::cout << One.name << "WINS! "<< bet << "+" << bet << "= $" << payBack << " New streak: " << One.streak << std::endl; } else { prize = (bet * One.streak); std::cout << One.name << "WINS! "<< bet << "x" << One.streak << "=$" << prize << " New streak: " << One.streak << std::endl; } //add to players money One.money = (One.money + prize); } else { //player loses int iHadMoney = One.money; One.money = (One.money - bet); std::cout << One.name << " LOSER! " << iHadMoney << "-" << bet << "=" << One.money << " New streak: 0 \n"; One.streak = 0; } } }; Machine CoinToss; //declair a coin tosser int main() { playGame(); return 0; } void playGame() { //game loop do { std::cout << "Coin Toss Casino, 0 = heads, 1 = tails \n\n"; //display player stats std::cout << One.name << " $" << One.money << std::endl; // player makes bet int playerBet; int playerChoice; std::cout << One.name << " Make your bet!: "; std::cin >> playerBet; std::cout << "\n What's your choice?: "; std::cin >> playerChoice; CoinToss.takeBet(playerBet, playerChoice); if(One.money <= 0) { gameOver = true; } system("pause"); system("cls"); }while(!gameOver); std::cout << "\n Game Over \n"; system("pause"); } Game info: player starts with 200 dollars, you make a bet then the coin is flipped. when you win it doubles your money, if you get on a streak it will start multiplying your bet by how high of a streak of right calls you are on. that's the game. you can download it here if you want to try it: http://27software.net/cpp/CoinTossCasino.zip I had a few specific questions I am sure will pop back into my mind once I get back into it tomorrow morning. Overall I just want to hear if I am using classes correctly or not. thanks
  5. AstralAaroN

    C++: Looking for critique (Tetris in allegro)

    Hey I just played your game, awesome man! :) I would be happy if I could make that happen.. anyway, it was a little bit unclear how to rotate the shapes, i got lucky and hit the right button to flip it a few times but am not sure what I hit. I think there might be a small glitch, when the game should have been over (when my blocks stacked up to the top) the next block went haywire and was switching from shape to shape very fast. gj anyway edit / addition: Just wondering if you have any experience with the SDL library and what you think about each one. which is easier to get started with etc..
  6. AstralAaroN

    Web page SQL calls without page reload.

    Hi are you using PHP for your server-side language? doing a simple AJAX hello world tutorial will probably open your eyes to how this is possible. let me know if you need some help
  7. AstralAaroN

    Extreme Newbie here - hello world :)

    Zahlman thank you, your post is awesome. I have been a little busy with things. I am going to refresh my memory on what I learned previously and then I am going to study your post and learn what you are talking about. thanks again!
  8. AstralAaroN

    (c++) 2 noob questions ! :)

    ok, I guess I was wrong :) in that case, I'm not sure why it is just closing.
  9. AstralAaroN

    (c++) 2 noob questions ! :)

    Quote:Original post by xiva For Q1 i tried all the posts (i think....) in your code you have int main() { } my understanding is that 'int' infront of main() is saying that the main function is going to return an integer. at the bottom of your main function make sure you have this: int main() { return 0; } [Edited by - AstralAaroN on May 30, 2009 8:39:16 AM]
  10. AstralAaroN

    Extreme Newbie here - hello world :)

    Ok I am ready to ask my next question which has to do with loading data from a text file.. first, I'll post the code for the entire 'Maze' game I created while messing around with arrays. #include <iostream> const int tileWide = 23; const int tileHigh = 10; bool gameOver = false; void printBoard(int[tileHigh][tileWide]); void locateOne(int& , int& , int[tileHigh][tileWide]); void move(const char direction, int[tileHigh][tileWide]); int iaBoard[tileHigh][tileWide] = { {1,2,2,2,2,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,2,0,2,0,0,0,2,0,2,0,2,2,2,2,2,0,2,2,2,2,2,0}, {0,0,0,0,0,2,0,2,0,2,0,0,0,0,0,0,0,0,2,0,0,2,0}, {2,0,2,2,2,2,0,2,0,2,0,2,0,2,0,2,2,0,2,2,0,2,0}, {0,0,0,0,2,2,0,2,0,0,0,0,0,2,0,0,0,0,0,2,0,0,0}, {0,2,2,0,2,2,0,0,0,0,0,0,0,2,2,2,2,2,2,0,0,2,2}, {0,0,2,0,2,0,0,2,0,2,0,2,0,0,0,0,0,2,0,2,0,0,0}, {2,0,0,2,2,2,0,2,0,2,0,0,2,2,2,0,0,0,0,2,0,2,0}, {2,0,2,0,0,0,0,2,0,2,2,2,2,0,2,0,0,2,0,2,0,2,0}, {2,0,0,0,0,0,0,2,0,0,0,0,0,0,2,0,0,2,0,2,2,0,0} }; int main() { do{ system("cls"); std::cout << "find your way to the bottom right corner.... "; printBoard(iaBoard); std::cout << "enter a direction (w = up, s = down, a = left, d = right):"; char cNextMove; if(iaBoard[tileHigh - 1][tileWide - 1] == 1) { gameOver = true; } else { std::cin >> cNextMove; } move(cNextMove,iaBoard); } while(!gameOver); std::cout << std::endl << " You made did it! you made it to the corner ! \n "; system("pause"); std::cout << "sorry you can't restart this game :) \n" << std::endl; return 0; } void printBoard(int iaBoard[tileHigh][tileWide]) { std::cout << " \n\n "; for(int i=0;i<tileHigh;++i){ std::cout << "\t"; for(int j=0;j<tileWide;++j){ std::cout << iaBoard[j]; } std::cout << std::endl; } } void locateOne(int& irRow, int& irCol, int iaBoard[tileHigh][tileWide]) { for(int iRow = 0;iRow < tileHigh ;++iRow) { for(int iCol = 0;iCol < tileWide ;++iCol) { if(iaBoard[iRow][iCol] == 1) { irRow = iRow; irCol = iCol; } } } } void move(const char direction, int iaBoard[tileHigh][tileWide]) { int iRowOne = 0; int iColOne = 0; locateOne(iRowOne, iColOne, iaBoard); int iOldRow = iRowOne; int iOldCol = iColOne; switch(direction) { case 'w': { --iRowOne; break; } case 's': { ++iRowOne; break; } case 'a': { --iColOne; break; } case 'd': { ++iColOne; break; } } if (iRowOne >= 0 && iRowOne < tileHigh && iColOne >= 0 && iColOne < tileWide) { if(iaBoard[iRowOne][iColOne] != 2) { iaBoard[iRowOne][iColOne] = 1; iaBoard[iOldRow][iOldCol] = 0; } } } the concept is simple.. there is a multi-dimensional array of numbers, 0's and 2's and a 1, you control the one starting in the top left and have to make it to the bottom right spot. you cannot move through 2's, only 0's. you can download the executable at http://www.27software.net/Maze.zip My question is about the array itself, for learning purposes I would like to be able to load the array (the level) in from a text file. The way I visualize this happening is in the text file there is something like this: map.txt tilesWide = 20; tilesHigh = 20; 1 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 2 0 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 from there, somehow get the 2 variables from tilesWide, and tilesHigh and put them into the 2 const variables from the Maze code: const int tileWide = ? const int tileHigh = ? then somehow sort the numbers delimited by the spaces / new lines into a multi dimensional array. am I close? is it a lot of work to do that? [Edited by - AstralAaroN on May 30, 2009 9:19:08 AM]
  11. AstralAaroN

    (c++) 2 noob questions ! :)

    edit:: deleted::: double posted by mistake.. this forum has some lag to it when I try to submit a post.. sometimes it sits for 5 - 10 minutes..
  12. AstralAaroN

    (c++) 2 noob questions ! :)

    Quote:Original post by xiva 2) When the player chooses say option 1 there will be a option to return can you undo/return or do you have to enter the code again ?? Hi I just started with C-plus-plus a few days ago and know how hard it is to learn what you want to do when you don't really know what you are trying to find out how to do :) I think this will help you though, try this code: #include <iostream> using namespace std; int x=100; int y=10; int main() { char answer; char answer1; bool bContinue = false; do { cout << "Name:"; cout << "Jack" << endl; cout << "Health:"; cout << x << endl; cout << ""<< endl; cout << ""<< endl; cout << ""<< endl; cout << "Fight? Press 1" << endl; cout << "Sleep? Press 2" << endl; cin >> answer; if (answer == '1') { cout << "Get ready to fight a RABBIT !!!" << endl; cout << "Ready ??? Press 1" << endl; cout << "Return ??? Press 2" << endl; cin >> answer1; if(answer1 == '1') { bContinue = true; } } if (answer == '2') { cout << "ZZZZZZZzzzzzzzzzzz ZZZZZZZZZZZzzzzzz" << endl; } }while(!bContinue); bool bRabbitDead = false; do { cout << "Rabbit has:" << endl; cout << y ; cout << "health" << endl; cout << "system pause here, press any key to kill the rabit" << endl; system("pause"); bRabbitDead = true; } while(!bRabbitDead); cout << "Rabbit is dead " << endl; return 0; } All I added was 2 do while loops and 2 boolean variables. if you don't know what a boolean variable is, it's just a variable that holds the value either 'true' or 'false' the first thing i did was make a boolean variable called bContinue and set it to false. next I put the first question into a do while loop like this: do { //this code } while (!bContinue); the above says while the variable bContinue is false, keep repeating the code. so theres no confusion, while(!bContinue) is just like saying while(bContinue == false) now after they choose to fight the rabbit you wanted to give them a chance to change their mind, so if they press 1 the loop will end and it will continue on to the next part of the code. If anything else is pushed it will do the loop over again and ask them if they want to fight or sleep. if (answer == '1') { cout << "Get ready to fight a RABBIT !!!" << endl; cout << "Ready ??? Press 1" << endl; cout << "Return ??? Press 2" << endl; cin >> answer1; if(answer1 == '1') { bContinue = true; } } after this I just did the same thing and made another do{}while(); with another boolean variable 'bRabbitDead'. keep at it :)
  13. AstralAaroN

    Extreme Newbie here - hello world :)

    Quote:Original post by oler1s Quote:is that just a way to write a member function for that class outside of the actual function code?Outside of the class declaration? Yes. show() is a member function of Dot, so you must define it as Dot::show(). By the way, :: is called the scope resolution operator. You've already seen it in use elsewhere. std::cout, for example. Quote:to keep things more organized?I'm not sure what you are referring to here. If you mean if the function definitions outside the class declaration is an organization issue, then yes. Quote:so show() is just a public function of the dot class?It's a member function. Whether it is public depends on the class declaration, where you would indicate the access specifier. thanks that did clear it up :) I had the right idea, just wasn't sure.
  14. AstralAaroN

    Extreme Newbie here - hello world :)

    This is one other thing that I've seen but cannot find any explanation on. I don't even know what to search for. [source code="cpp"] void Dot::show() { apply_surface( (int)x, (int)y, dot, screen ); } the :: is completely throwing me off. there is also a Dot class, so I figure it has something to do with making that function work for the dot class.. but its still confusing me on what exactly it is doing. ok I think I just made some sense of this... inside the dot class i noticed the function was declared "show()" and i know about classes and functions inside of them.. is that just a way to write a member function for that class outside of the actual function code? to keep things more organized? so show() is just a public function of the dot class?
  15. AstralAaroN

    Extreme Newbie here - hello world :)

    Quote:Original post by Koobs C++ is pretty flexible when it comes to whitespace. The function could've also been written as: SDL_Surface * load_image( std::string filename ) or SDL_Surface* load_image( std::string filename ) It means that the function 'load_image' returns a pointer to a 'SDL_Surface', ie. a 'SDL_Surface*' (pronounced SDL surface pointer ) -Joel thanks, that cleared it up for me.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!