khoadd

Members
  • Content count

    24
  • Joined

  • Last visited

Community Reputation

316 Neutral

About khoadd

  • Rank
    Member
  1. Game's MenuState and Game's Loop

    @ActiveUnique: It is clear(more than the old). Thank you so much. :) @Malabyte: Thanks for your advice. Maybe I just look one way. Your solution can be a good one. I am thinking about it. Thanks a lot :)
  2. Game's MenuState and Game's Loop

    @mark ds: wow it is really simple. Thank you so much. @ActiveUnique: I still not figure out what you mean. Please explain! I really like to look for more ways.
  3. In normal application or non-animation application, we use event-driven. It means that just when there is at least one event inside event queue, the program will processes. If not, it will wait until at least one. During of that waiting time, the program does nothing.   For game, we use game loop (I saw others called it: loop-driven) because there are many things happening and need to be updated even if user did not input anything.   My question is:   With menu state (the menu for us to choose "Start new game" | "Load game" | "Continue Game" | "..." - not in-game menu/GUI), it is like normal app. It waits for user input. It does not need a real-time loop. So how we can implement it and attach it to our game?   Here is an overview of my code:   // class Game has a "StateManager" field and a loop like this   while(running) { -get Event -process Event -update -draw }   // inside update/draw, i simply call update/draw of "current_state" of StateManager   if the state is GamePlay, It is ok. If it is MenuState, it is my problem.
  4. how many threads for game loop

    Thank cozzie Thank Dave Hunt Thank frob
  5. Hi all,   I saw java game used 2 threads. One thread for game loop (update, render) and one for handling input (keyboard, mouse). Game loop thread was manually created by programmer. The other cames from "Event Dispatcher Thread" of .JFrame.   On the other hand, I saw C++ game had just one thread (Example SDL or DirectX game progamming tutorials ). It is like this:   ... ... while(running) { // handle input or handle messages / events // update // render } ... ...   So, my question is "which one should I use?".   Thanks!   P/S: please explain why
  6. @shacktar: the tut that i followed was OpenGL not SDL It's here: http://lazyfoo.net/tutorials/OpenGL/01_hello_opengl/index2.php I compiled the source code but there wasnt any error. Everything ran fine but the frame of window disappeared. I tested the code from author. The window from that code has right frame (border).   I believed the error came from my code but why no error has been found when I compiled. Is it a semantic error? I compared 2 source code files and I saw they are not different.   Hic I go mad right now   
  7. I am following tutorial from lazyfoo,net I've finished the first lesson. Everything is OK, I mean there isnt any error in my code. I compiled successfully. However, my result looks like this: [attachment=14254:no frame.png]   My tool and my lib: Windows 7 SP1 32bit ultimate freeglut 2.8.0.1 MinGW (latest) OpenGL 2.1   I dont kown how to fix it. Plz help. Thanks!
  8. I checked some games and I found something. I do not know if what i thought is right or wrong. The games I play are [url="https://www.teeworlds.com/"]Teeworlds[/url], [url="http://www.nplay.com/BeGone/"]Begone[/url], and league of legends. I guess: - In Teeworlds (2D scrolling shooting) and Begone (FPS), each game host on different server. We connect to server of game developer (let us call it: main server) to get IP and port of game host. After receiving IP and port, we connect to game host and play. This way, main server's job is very easy. It just manages players' state to decide which player should receive update info (game host list ...). It also does not worry about game state. It just maintains game list and receive game status (like full or not full, max player). If game host is turned off, it removes game out of list. We cannot create our games following this way. If we want to own a game, we must run another game host. - In the other hand, LOL give us an ability to create game. Therefore, I guess there is just one server for all function. I create game, join game on the given server. It also means that server must be super strong to handle all things. The first way seems to be easy to implement. Each game manages its resources on its host. Main server is dedicated to process updating game host info and player info to clients. However, for card game, we do not want player waiting for someone hosts the game to join. If there is no game host, no one can play. We want player create account, login and join game. If there is no game, player can create game by himself. Therefore, we move to second way. All things are in the given server. It is only one. This way seems to be suitable. However, I wonder if it is theory or practice. For each connection, we need a pair of sockets and one thread to hold communication. For each game, we need at least one thread to run. For instance, we have 400 players and 100 games (4 players per game); we will need 400 threads of communication + 100 game threads + 1 listening thread (and more for server system). The server must be strong to handle things. Is there any server out there strong enough for this (of course not super mainframe computer)? Above is what i draw from playing and watching game. I know I miss many technical details and knowledge. With the famous and massive game like LOL that has thousands of people and thousands of games at the same time, the story will be different. Now, I am very confused how to create a good client-server game. I need tutorials and advices. I search through internet, but there is not much information. I tried with “game lobby”, “game room management” key word, but they doesn’t give me useful info. I need help!
  9. My Java exercise is creating a card game like Microsoft Hearts plus multiplayer via internet. I decided to let player create game room. When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist. The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server. If I send an object, I can use arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time) I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example: We have Game : a b c d e f Index : 1 2 3 4 5 6 We remove c Game : a b d e f Index : 1 2 3 4 5 In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not existing, but its index is 3. It is still there. Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.
  10. Texture Error

    [quote name='BitMaster' timestamp='1341816012' post='4957167'] I would also advise to take what else KhoaVN said with a lot of grains of salt. I freely admit being biased against excessive user of 1337-speak but at the very least the post I quoted is very much not helpful and shows a serious lack of understanding regarding the issues at hand. [/quote] @BitMaster: You're right. That's my fault. @BeginGamer: Sorry for bad things.
  11. Texture Error

    Yup, at this point, no syntax error, you should debug by yourself. I am sure u will find the answer. I cant help u now coz that is ur code and just u know how it works. Syntax error is always easy to find than meaning error. [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Good luck [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
  12. Texture Error

    Try my last solution. I believe that it is And whether it is right or wrong, Plz reply
  13. Texture Error

    oh sorry, I found another. vertor operator [] returns a "reference" not an "int". So my advice is to use a GLint* (int pointer) instead of vector<GLint> example: GLint* SpriteSheep = new GLint[nSize]; then u can use uploadImage(image, SpriteSheet[i]);
  14. Texture Error

    Another problem i found in your logic: if temp is null how can u call func : SDL_CreateRGBSurface() if temp is null, u should return.