• Content count

  • Joined

  • Last visited

Community Reputation

183 Neutral

About Motoky

  • Rank
  1. 3D Line Equation?

    I've come across some books that are really detailed and go through how they solve something and I prefer. I hate books that just give you an answer without any meaning behind it and expect you to figure out for yourself if you don't have a clue what some symbols might even mean or why nothing is actually showing up on the internet because they have written it down differently.   Anyway, I got passed that and onto the next set of exercises which is about finding the slope, y-intercept for each equation and the number of solutions. Well, I thought that a system of equations had to consist of more than one equation, if they don't, then I am completely lost because not even my previous books showed a system of equations with just one equation...   Anyway, the equation is:   x + y = 7   So the slope would be -1. The y-intercept would be: y = -x + 7.   Earlier in the book it tells you that to find out how many solutions a system of equations has by checking to see if the slopes of both equations are the same. If they are NOT the same, it has one solution, if it does, you then need to find the y-intercept and check to see if b1 and b2 are the same. b1 in this question would be 7.   So I have m1 = -1, and b1 = 7. The answer gives me that, but with m2 = 1/3 and b2 = 2/3, with only one solution.   I know you mentioned that I should focus on the theory and I guess understanding how it works, but I just wish someone could shed some light on this one so I can move on. If all of the exercises are like this, where they are giving me false answers or not explaining how they got the answer, I just don't see the point in the exercises...
  2. 3D Line Equation?

    For 2D, the book gives you this formula to get the equation:   (y - y1) = m(x - x1)   y1 and x1 being the first coordinates. m being the slope.   So, one of the questions in the book is to find the equation of 2D points as well, like:   (0, 10) and (5, 0)   (y - 10) = m(x - 0)   m = (0 - 10)/(5 - 0) = (-10)/5 = -2   y - 10 = 2x   y = 2x + 10     Anyway, there is only a little bit of info in the book, the answer isn't even an equation, but it's a vector...   You have:   ?x = x2 - x1 ?y = y2 - y1 ?z = z2 - z1   So with the coordinates, (2, 0, -1) and (3, 4, 5), it would be:   ?x = 3 - 2 = 1 ?y = 4 - 0 = 4 ?z = 5 - (-1) = 6   This is why I was confused because it was asking for an equation, not a vector... The answers were a bit further on. So I got them right, but it wasn't really worded very well because I was trying to find an equation...   Thanks anyway.
  3. 3D Line Equation?

    I am currently learning from a book called Beginning Maths and Physics for Game Programmers. I had trouble with this book quite early on due to the fact that I had completely forgotten most of the maths I had learnt at school so I went through some Algebra and Linear Algebra books to help me and I feel I am doing better with this book, this time around.   Now, I am confused about a question in the book. It says, "Find the equation of a line connecting the following pairs of points:"   It continues to list a few points for a 2D coordinate system, but the last two is a 3D coordinate system and the two points for one of the questions are:   (2, 0, -1) and (3, 4, 5)   Now, the book doesn't tell you at all how to find out how to get the equation of three points, only two. I have tried applying different ways of doing it, but it never turns out right. I would have thought, when you come to exercises or tasks, you should be at least taught how to do it and not thrown into the dark because you learnt how to do the bare minimum.
  4. Books & Libraries

    Thanks for the info, will definitely pursue into using ASIO in the near future as well as reading those books.   It's something I should consider doing at some point due to how heavily online gaming has become or even social networking involved in games. Very simple things like being able to share high scores across social networking sites, adding friends on mobile games or just general interacting with another players world.   With programs like an instant messenger, it's mainly for learning purposes, but you wouldn't need a server for that would you, or would you have one person lets say, open some sort of lobby that everyone can join, or be invited to.
  5. Books & Libraries

    Cheers, I had heard about ASIO, but wasn't too sure if it was still widely used. I haven't heard of RakNet.   I have heard people mention WinSock, is that used still, does it accomplish the same things that ASIO or RakNet do?   About the books, are they more practical learning or are they mainly just for reading purposes and not participating in exercises?   I would also like to ask, would be a good idea to learn about servers and setting up a server if I were to start learning about networking?   Another thing I want to mention is that I am currently learning how to use the SFML library, it has a built in Network Module, just wondering if that is also something I should look into. I am using an SFML book at the moment and I am pretty sure it includes network programming in that.
  6. I've been through one book fully of C++, I didn't find it to be very helpful for a beginner at the time, I was very confused with a lot of the material, kind of set me back a bit, especially containers, file I/O, etc. On my second book, relearning stuff that I was confused about and little bits of information that I never knew before. I feel I've become better at C++ even though I've only been doing it for a few years.   Anyway, I'm mainly wanting to work on games, but it's always good to learn about other stuff besides games and how they work. Now, networking is something I've not delved into yet, it's always been in the back of my mind and when I should learn a bit about it.   I was just wondering which books you would recommend learning from about network programming, networking in general and maybe a good library for C++ to use. I've just thought about working on an Instant Messenger program and wouldn't even know where to start.
  7. I've always wondered, when developing a game, there are obviously going to be a lot of different people with different specs and such. This is why you usually provide players with graphical settings so they can adjust it to suit there machines.   Now, I haven't made anything myself as of yet, but currently working on clones of games while adding to my own ideas and documents. How does resolution actually work? When you display a 2D game, you have all of the sprites in specific positions, when you increase the resolution of a game, those positions are going to change and aren't the sizes of the sprites going to change as well?? I have only messed with viewports in SFML before, so not 100% sure on how it all works, or even if that's the right thing to use.   Do you develop your games based around 1920 x 1080, or do you have to reset the positions and sizes of sprites, collision detection, etc. around different resolutions??
  8. What library to choose to write games in C + +

    I'm only in my early 20's and I started programming at like 17. I had no experience with any languages and was going into it blind. Didn't really have any idea which forums to go on, I did a bit of research and decided on using C++.   I have to say, it was difficult. I was having trouble with the most basic of programs. I also wasn't committed enough and wasn't studying enough each day.   I've been through a couple of books, some weren't very detailed and didn't really explain some of the basic stuff, so when I moved onto advanced projects, it was tough. I'm actually learning C+11, decided I needed a good book and to have a go at the new standard and I'm doing way better than I did when I first went into programming.   I tried out SDL, got through several lessons, but it just felt messy. A lot of the times my code wasn't working properly. The libraries weren't linking properly. It put me off it to be honest. I've just been learning C++ and dabbled in DirectX which I really enjoyed. Jumped into SFML last week, took a bit to get it up and running, was trying to get it running on Visual Studio 2012, but it just wasn't cooperating, so I went back into the 2010 version and got it up and running. It's so much easier to use. You will get windows and shapes up in minutes of programming. The names of classes, functions, etc. are very easy to understand. They have the documentation on the website.   I would recommend SFML for someone just beginning.
  9. Yeh I can email it to you. Just make sure you have SDL all set up though.   PM me your Gmail.   Cheers.
  10. I have been working through these tutorials for a while now. I have been stuck a few times, but managed to overcome it on my own or through some very helpful posters on here.   I have the program all and running. The program displays to circles of the same size and you are meant to move one circle towards the other and they will collide together. Once they meet, the circle stops.   The problem I am having is with keyboard input. I've got it working in previous tutorials, but I have been slowly changing my code to spread across multiple header files and source files to make it easier to read.   I can't upload the project because it's too big as a whole. I also have trouble getting code to appear properly without it looking like a mess and readable on here.   I guess I will upload an image of each section that I am having trouble with.     Okay, from the image. The first section is where I poll for events. I then try to retrieve input for my dot object. I send that same Event structure to the function which is shown in the second section. It checks for the key down event and checks the type of key that was pressed and increases or decreases the velocity of the circle depending on the key that was pressed. It also checks to see if that key was released and then sets the velocity to 0 making the circle stop moving. Again, if nothing was pressed, it goes back to the first section and checks to see if the type of event was a quit event, control is returned to the main function in the third section.   In the third section, if the function returned false, quit becomes true and the program exits. This event works, it quits when I press on the 'X'. If I didn't press 'X', the program should return control to main and move the circle as shown in the function moveSprites(), clears the screen to white, displays the circles, flips the back buffer and caps the frame rate to 20 FPS.     It seems like a lot to follow, but for some reason, the circle just isn't moving. I've been through my code a hell of a lot and I can't see what the problem is. I've compared it to a previous SDL project and I've only changed a few things, and all I have done is handled all of my input inside the SDLManager class. I've even tried changing this project to closely match my previous project and it's still not working.
  11. I had a look through my code before looking at your reply and I noticed I hadn't even started the timer. I also initialized a Timer object in my Main source file along with the SDLManager header file. I was trying to start the timer with a different Timer object, but retrieve the FPS on another Timer object...   I decided to initialize my timer in my Main source file, get rid of it in the SDLManager. The program is up and running now, but still having a little trouble with the movement of the square, but I will sort that out myself. I've had this problem before and I managed to get it fixed before.     Thanks a lot though.
  12. Hey, I am currently working through Lazy Foo's tutorials. I have been doing pretty well with the previous tutorials. Obviously running into walls, but managed to get passed them due to silly little errors or mistakes I couldn't see which were to blatant when I finally did find the problem...   Anyway, the problem I am having is with the Timer class. I've got it working in previous projects, but it's just cooperating in this one project.   The function I am talking about is it returns the time in milliseconds, but it is all based on whether the timer is running and if it's paused or not.     I have uploaded my project. It's probably not perfect, but I am just trying to get it up and running before I make modifications, add more comments and such. I can't seem to copy and paste code properly, it just comes out as a jumbled mess with huge gaps between nearly every word and it would take me ages to sort it out, so it just quicker to upload my project and you can have a look through it all.   Like I said, it's just the Timer class giving me trouble. It just stops at the getTicks() function when I debug. It stops at the first line in that function which is:   if(started == true)     Now this exact class works in other projects.
  13. drawing clouds in a flight sim

    I'm still a newbie, but I would probably suggest using some sort of particle system.   I did think of using a 3D model of a cloud, but when you go through it, it wouldn't display anything inside it. So a particle system would work well.     The way you would implement it would depend on what API or engine you are using.
  14. SDL Problem

    Ok, I had trouble logging onto the site... So it's taken a bit of time to reply.   I've sorted out that problem I originally had. I will put more effort into catching errors and finding out what part of my code is having trouble. By doing this I managed to find out that it was where I was trying to load the background file. I had it saved as a PNG while I was trying to load a BMP. I changed the file format of my image.     Now I am just having a hell of a lot of trouble with the SDL_mixer library. When I debug, it stalls at the point of loading a sound file. I've tried searching on the internet, but I'm not getting any answers.   Then I started getting this System Error:   "The program can't start because libstdc++-6.dll is missing from your computer. Try reinstalling the program to fix this problem."   I have no idea what file this is, I wasn't getting this error before. I tried redownloading the SDL_mixer library, remaking the project and the same thing happens...
  15. SDL Problem

    My Sound header file       #include     <SDL_mixer.h> #include     <string> using     namespace std; class     Sound { public     : Sound(); ~Sound();     bool initSound();     bool loadFile(); Mix_Chunk* loadSound(string filename);     void playSound(int playWhich);     void pauseSound();     void stopSound();     void shutDown(); private     :       Mix_Music* music;     Mix_Chunk* scratch; Mix_Chunk* high; Mix_Chunk* med; Mix_Chunk* low; };   Sound Source Code     #include     "Sound.h" Sound::Sound() { music = NULL; scratch = NULL; high = NULL; med = NULL; low = NULL; } Sound::~Sound() { } bool     Sound::initSound() {     int freq = 0; Uint16 format = 0;     int channels = 0; Mix_QuerySpec(&freq, &format, &channels);     if(Mix_OpenAudio(freq, format, channels, 4096) == -1)     return false;     return true; } bool     Sound::loadFile() { music = Mix_LoadMUS(   "beat.wav");     if(music == NULL) {     return false; } scratch = loadSound(   "scratch.wav"); high = loadSound(   "high.wav"); med = loadSound(   "medium.wav"); low = loadSound(   "low.wav");     if((scratch == NULL) || (high == NULL) || (med == NULL) || (low == NULL)) {     return false; }     return true; } Mix_Chunk* Sound::loadSound(string filename) { Mix_Chunk* sound = NULL; sound = Mix_LoadWAV(filename.c_str());     if(sound == NULL) {     return NULL; }     return sound; } void     Sound::playSound(int playWhich) {     switch(playWhich) {     case 1:     if(Mix_PlayChannel(-1, scratch, 0) == -1)     break;     case 2:     if(Mix_PlayChannel(-1, high, 0) == -1)     break;     case 3:     if(Mix_PlayChannel(-1, med, 0) == -1)     break;     case 4:     if(Mix_PlayChannel(-1, low, 0) == -1)     break;     default:     break; } } void     Sound::pauseSound() {     if(Mix_PlayingMusic() == 0) {     if(Mix_PlayMusic(music, -1) == -1)     return; }     else {     if(Mix_PausedMusic() == 1) { Mix_ResumeMusic(); }     else { Mix_PauseMusic(); } } } void     Sound::stopSound() { Mix_HaltMusic(); } void     Sound::shutDown() { Mix_FreeChunk(scratch); Mix_FreeChunk(high); Mix_FreeChunk(med); Mix_FreeChunk(low); Mix_FreeMusic(music); Mix_CloseAudio(); }   My Main Source File   #include     <SDL.h> #include     <SDL_ttf.h> #include     "Sound.h" #include     <string> using     namespace std;   const     int SCRN_WIDTH = 640; const     int SCRN_HEIGHT = 480; const     int SCRN_BPP = 32; SDL_Surface* videoSurface = NULL;   SDL_Surface* background = NULL;     SDL_Surface* instruction1 = NULL;     SDL_Surface* instruction2 = NULL;     SDL_Surface* instruction3 = NULL;     SDL_Event   event; TTF_Font* font = NULL; SDL_Color fontColor = {255, 255, 255}; Sound* soundMgr = NULL;   bool     initSDL();     bool     initTTF(); bool     loadFiles(); SDL_Surface* loadBMP(string filename);   void     applySurface(int x, int y, SDL_Surface* src, SDL_Surface* dest, SDL_Rect* clip = NULL);   void     setText(); void     renderText();     void     shutDown();   int     main(int argc, char** argv) {     bool quit = false;     if(!initSDL())     return -1;     if(!loadFiles())     return -1;     if(!soundMgr->initSound())     return -1; setText(); applySurface(0, 0, background, videoSurface, 0); renderText();     while(!quit) {     if(SDL_PollEvent(&event)) {     if(event.type == SDL_KEYDOWN) {     if(event.key.keysym.sym == SDLK_1) { soundMgr->playSound(1); }       if(event.key.keysym.sym == SDLK_2) { soundMgr->playSound(2); }     if(event.key.keysym.sym == SDLK_3) { soundMgr->playSound(3); }     if(event.key.keysym.sym == SDLK_4) { soundMgr->playSound(4); }     if(event.key.keysym.sym == SDLK_9) { soundMgr->pauseSound(); }     if(event.key.keysym.sym == SDLK_0) { soundMgr->stopSound(); } }     else if(event.type == SDL_QUIT) { quit =   true; } }     if(SDL_Flip(videoSurface) == -1) {     return -1; } } shutDown();     return 0; } bool     initSDL() {     if(SDL_Init(SDL_INIT_EVERYTHING) == -1)     return false; videoSurface = SDL_SetVideoMode(SCRN_WIDTH, SCRN_HEIGHT, SCRN_BPP, SDL_SWSURFACE);     if(videoSurface == NULL)     return false;     if(!initTTF())     return false; SDL_WM_SetCaption(   "Playing Sound", NULL);     return true; } bool     loadFiles() { background = loadBMP(   "background.bmp");     if(background == NULL)     return false;     if(!soundMgr->loadFile())     return false; font = TTF_OpenFont(   "robotic.ttf", 24);     if(font == NULL)     return false;     return true; } bool     initTTF() {     if(TTF_Init() == -1)     return false;     return true; } SDL_Surface* loadBMP(string filename) { SDL_Surface* tempSurface = NULL; SDL_Surface* optimizedImage = NULL; tempSurface = SDL_LoadBMP(filename.c_str());     if(tempSurface != NULL) { optimizedImage = SDL_DisplayFormat(tempSurface); SDL_FreeSurface(tempSurface);     if(optimizedImage != NULL) { Uint32 color = SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF); SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, color); } }     return optimizedImage; } void     applySurface(int x, int y, SDL_Surface* src, SDL_Surface* dest, SDL_Rect* clip) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface(src, clip, dest, &offset); } void     setText() { instruction1 = TTF_RenderText_Solid(font,     "Press 1, 2, 3, or 4 to play a sound effect", fontColor); instruction2 = TTF_RenderText_Solid(font,     "Press 9 to play or pause the music", fontColor); instruction3 = TTF_RenderText_Solid(font,     "Press 0 to stop the music", fontColor); } void     renderText() {     applySurface((SCRN_WIDTH/2) - (instruction1->w/2), (SCRN_HEIGHT/2)/2, instruction1, videoSurface);     applySurface((SCRN_WIDTH/2) - (instruction2->w/2), (SCRN_HEIGHT/2), instruction2, videoSurface);     applySurface((SCRN_WIDTH/2) - (instruction2->w/2), (SCRN_HEIGHT/2)/2 + (SCRN_HEIGHT/2), instruction3, videoSurface); } void     shutDown() { SDL_FreeSurface(background); SDL_FreeSurface(instruction1); SDL_FreeSurface(instruction2); SDL_FreeSurface(instruction3); soundMgr->shutDown(); TTF_CloseFont(font); TTF_Quit(); SDL_Quit(); }   It still comes out quite terrible even using the [ code ] brackets.