Advertisement Jump to content
  • Advertisement

Meta Adam

  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Meta Adam

  • Rank
  1. Meta Adam

    A good OpenGL Book

    Okay, today I made it to barnes and noble, and they had the superbible, but they also had Beginning Game Programming, which instead of ogl its DX. It also came with a 3d modeler, a sound editing program, and code and stuff... So it seemed pretty good.
  2. Meta Adam

    A good OpenGL Book

    Hello everyone, I've been shopping Amazon for a good OpenGL book, I have seen a couple that had good customer ratings, and looked good to me. They are "OpenGL SuperBible 3rd edition, by Richard S Wright and Benjamin Lipchak", and "OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 1.4, Fourth Edition, by a large group of people" Does anyone have thoughts on buying either one of these. It has been a while since I have had money, and almost have enough to scratch up for this. As for free ebooks, I have taken a look at The Redbook, and skimmed it, but I want something I can read off of the computer, because I get headaches easily looking at the screen, that's why most programs I write out are on paper first =). Thanks. [edit: I have close to no knowledge about OGL.]
  3. Meta Adam

    SDL problems :-(

    Post the code please.
  4. Meta Adam

    input question

    Ohh hehe yeah, you only need 1
  5. Meta Adam

    input question

    what do you mean? Like a string called "command", well just replace "myString" with command. String is a declared and defined like a type like int or char.
  6. Meta Adam

    input question

    #include <iostream> #include <string> using namespace std; int main() { string command; //changed to command cout<<"What do you want to do?\n"; cin>>command; if(command == "eat") { cout<<"You eat.\n"; } else cout<<"You do nothing, because I didn't understand it.\n"; return 0; } I think that's what you want. You just make the if statements the options the person could do.
  7. char* verylargemultidimensionalarrayofcharpointersthatmightbeabletobeusedasthemanypossibilitiesofthewarhead[100][300];
  8. Meta Adam

    SDL Closing Too Fast

    Yes, I know you get this all the time about the console, but this time it's SDL. It's closing when it shouldnt. It should be polling for an event, and then maybe closing. Can someone help? #include <SDL/SDL.h> #include <iostream> #include <cstdlib> #include <time.h> #define SWIDTH 800 //screen width #define SHEIGHT 600 //screen height #define PWIDTH 120 //paddle width #define PHEIGHT 20 //paddle height #define BWIDTH 15 //ball width #define BHEIGHT 15 //ball height #define BLWIDTH 70 //block width #define BLHEIGHT 25 //block height #define WORKWIDTH 700 //Area that the blocks are drawn width #define WORKHEIGHT 250 //Area that the blocks are drawn height #define SIDESWIDTH 50 //Blank area on the sides of the screen where the ball can go #define TOPHEIGHT 100 //Blank area on the top of the screen where the ball can go SDL_Surface *screen; SDL_Surface *back; SDL_Surface *paddle; SDL_Surface *ball; SDL_Surface *blocks[6]; void loadIMG() { back = SDL_LoadBMP("back.bmp"); paddle = SDL_LoadBMP("paddle.bmp"); ball = SDL_LoadBMP("ball.bmp"); blocks[0] = SDL_LoadBMP("bblock.bmp"); blocks[1] = SDL_LoadBMP("gblock.bmp"); blocks[2] = SDL_LoadBMP("oblock.bmp"); blocks[3] = SDL_LoadBMP("pblock.bmp"); blocks[4] = SDL_LoadBMP("rblock.bmp"); blocks[5] = SDL_LoadBMP("yblock.bmp"); } void drawIMG(int x, int y, SDL_Surface *img) { SDL_Rect dest; dest.x = x; dest.y = y; SDL_BlitSurface(img, NULL, screen, &dest); } void drawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2) { SDL_Rect dest; dest.x = x; dest.y = y; SDL_Rect dest2; dest2.x = x2; dest2.y = y2; dest2.w = w; dest2.h = h; SDL_BlitSurface(img, &dest2, screen, &dest); } struct Block { int color, yloc, xloc; }; struct Board { void setBoard(); Block board[10][10]; }; void Board::setBoard() { for(int y=0;y<10;y++) { for(int x=0;x<10;x++) { board[x][y].xloc = x*BLWIDTH+SIDESWIDTH; board[x][y].yloc = y*BLHEIGHT+TOPHEIGHT; board[x][y].color = rand()%6; } } } void drawBlocks(Board dbBoard) { SDL_Surface *temp; for(int y=0;y<10;y++) { for(int x=0;x<10;x++) { if(dbBoard.board[x][y].color == 0) temp == blocks[0]; if(dbBoard.board[x][y].color == 1) temp == blocks[1]; if(dbBoard.board[x][y].color == 2) temp == blocks[2]; if(dbBoard.board[x][y].color == 3) temp == blocks[3]; if(dbBoard.board[x][y].color == 4) temp == blocks[4]; if(dbBoard.board[x][y].color == 5) temp == blocks[5]; drawIMG(dbBoard.board[x][y].xloc, dbBoard.board[x][y].yloc, temp); } } } int main(int argc, char* argv[]) { srand((unsigned)time(NULL)); Board myBoard; myBoard.setBoard(); if(SDL_Init(SDL_INIT_VIDEO) < 0) { std::cout<<"Cannot initialize SDL.\n"; SDL_GetError(); exit(1); } screen = SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE | SDL_DOUBLEBUF); if(screen == NULL) { std::cout<<"Cannot set video mode\n"; SDL_GetError(); exit(1); } loadIMG(); drawBlocks(myBoard); int done = 0; while(done < 1) { SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT) {done = 1;} if(event.type == SDL_KEYDOWN) { if(event.key.keysym.sym == SDLK_ESCAPE) {done = 1;} } } } }
  9. Meta Adam

    rand and srand are killing me

    Hee, alright, Thanks!
  10. Meta Adam

    rand and srand are killing me

    Yah, I know what a struct is but I thought I could get by with using one, but I guess I can't. Is it because a union is tied to one block of memory so if 1 of them gets edited the others do too? Thought I was gonna be able to use less memory =).
  11. I have a question, I have 3 different rand()%10's inside 2 for loops, and the output is random numbers but they are the 3 same in a row, #include <iostream> #include <cstdlib> #include <time.h> using namespace std; union Block { int color, relxloc, relyloc; }; Block board[10][10]; int main() { srand((unsigned)time( NULL )); for(int y=0;y<10;y++) { for(int x=0;x<10;x++) { board[x][y].color = rand()%10;; board[x][y].relxloc = rand()%10;; board[x][y].relyloc = rand()%10;; cout<<board[x][y].color<<" "<<board[x][y].relxloc<<" "<<board[x][y].relyloc<<endl; } } return 0; } and my output is like 111 666 333 888 666 222 666 222 times 100, for every cell on the board. How can I get it to change every time so its like 356 864 373 266 like that? Thanks.
  12. Meta Adam

    vector and structs

    please? It seems every time I have a second question in a thread it never gets answered.
  13. Meta Adam

    vector and structs

    Is it legal to do this though, //changed it to class, because I needed the initializer //Item Class class item { string name; itemEffect effect; public: item(string name, itemEffect effect) : effect(effect), name(name) {}; }; //rather than having "int id;" in the class, the array number is it's ID item items[16] {("Potion", HEAL10), ("Extra Potion", HEAL50), ("Holy Water", HEAL200), ("Super Heal", HEAL1000), ("Ancient Herbal Water", HEALALL), ("Phoenix Down", BRINGBACKTOLIFE), ("Buffness Drink", STRUP3), ("Building Plant", STRUP10), ("Energy Drink", STAUP3), ("Energy Plant", STAUP10), ("Ancient Drink", WISUP3), ("Ancient Leaf", WISUP10), ("Level Orb", LVLUP), ("HP Orb", HPUP), ("MP orb", MPUP), ("Name Switcher", NAMECHANGE)}; //inventory class //uses the vector to add and remove the above 16 initialized Items. class inventory { public: void addItem(); void takeAwayItem(); void outCantUseItem(); private: vector<item> inventory; }; Thanks.
  14. Meta Adam

    vector and structs

    thanks guys =)
  15. Meta Adam

    vector and structs

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!