XTAL256

Members
  • Content count

    720
  • Joined

  • Last visited

Community Reputation

106 Neutral

About XTAL256

  • Rank
    Advanced Member
  1. Game loop in Qt

    I think i will just go with the QTimer option. My game is 2D and isn't too complicated, so timing won't need to be terribly accurate.
  2. Inexplicable error

    Easiest thing would be to try adding more buttons, or changing their positions, to see how that affects the layout.
  3. I have recently decided to use Qt for making my 2D game. All was going well until i started thinking about the game loop. Previously (when i used SDL), it was something like this: [code] int main(int argc, char* argv[]) { // Setup stuff // ... int lastTime, dt, timeLeft; while(!appQuit) { while (SDL_PollEvent(&sdlEvent)) { // <-- Process any events in the queue if (sdlEvent.type == SDL_QUIT) { appQuit = true; break; } Event::eventProc(sdlEvent); // <-- Do my own event processing, for GUI and stuff } lastTime = SDL_GetTicks(); clearScreen(); if (Game::isStarted && !Game::isPaused) Game::update(); // <-- Update game state (physics) GUI::drawScreen(); // <-- Draw everything glFlush(); SDL_GL_SwapBuffers(); dt = SDL_GetTicks() - lastTime; timeLeft = (1000/Settings::frameRate) - dt; if (timeLeft > 0) Sleep(timeLeft); // <-- Sleep until next update } // Shutdown stuff // ... }[/code] I was also intending on using a different rate for graphics and physics updates, as [url="http://gafferongames.com/game-physics/fix-your-timestep/"]this guy[/url] says. But now with Qt, i don't have access to the main event loop, so i am not sure how to do this. Some have suggested using a QTimer, but i don't like that approach for a number of reasons. Firstly, the resolution may not be enough for high frame rates. And if i separate logic and graphics updates, i would need two separate timers. Maybe that would not be a problem, but it doesn't sound like a nice way to do it. There is also the question of how often to update. Most people just write a loop that updates as fast as it can - i.e. with no sleeping in between. I don't like this idea because it uses an unnecessary amount of CPU for rendering a fairly simple 2D game. And regardless of your opinion on this, i have my reasons, and so i would like to be able to set a maximum frame rate for my graphics and/or physics updates. So, does anyone have any ideas? There must be some way to do this in Qt. Using Qt (for anything, let alone games) is a joy, and i really do not want to go back from it now.
  4. Jailbreaking iPod touch 4

    Yes, thank you. At the time of posting, http://helpmejailbreak.com mentioned that greenpois0n was available as an untethered jailbreak for 4.2.1 but their website was unavailable. It is up and running today, so i will check it out.
  5. Jailbreaking iPod touch 4

    Ok, first things first. As far as i know, jailbreaking iPhones/iPods [i]is[/i] legal, so there should be no issues posting here. But if i am wrong, i don't mind if this post is closed. Now, as the title suggests, i am planning on jailbreaking my iPod Touch. It is 4th generation and iOS version 4.2.1, although when i got it a few months ago i think it was 4.1 (the 4.2.1 upgrade was available as soon as i connected it to iTunes, so i upgraded it). I have read up on the jailbreaking process at websites like http://helpmejailbreak.com and wikipedia, and have downloaded some of the software required (ZiPhone and redsn0w_win_0.9.6b6). But before i attempt to jailbreak, there are still a few critical things i need to know:[list=1] [*][url="http://helpmejailbreak.com/device/bdewl/"]Apparently[/url] the patch for 4.2.1 is tethered. Since i don't want this, i may have to downgrade to 4.1 in order to jailbreak. I may be able to restore to 4.1 since i think that's what my iPod came with, but i'm not sure. Is this possible to do so, or is there an untethered jailbreak for 4.2.1? [*]Will i lose any app data, either if i restore to 4.1 or when i jailbreak? I don't want to lose saved progress in any of my games. [*]The main reason for doing this is so that i can access the contents (i.e. music) of my iPod because it will appear as a drive in Windows. Is this true, and will i be able to access the whole drive (i.e. app data, executables, etc), or at least just the music folder? [*]After i do it, will i have any problems later? For example, what would happen when new iOS updates are released - will i have to wait for a new patch for each new update? Or could the patch crash and lose data?[/list]
  6. [quote name='Oberon_Command' timestamp='1295201782' post='4759705'] [quote]The UI has context menus and property dialogs that i want to be specific to each object type.[/quote] If you want to only have specific dialogs for each TYPE, then I might create some mapping in the UI of the type of object to its menu tree object (or whatever you're using), probably using Qt's equivalent to std::map. This mapping would exist in the UI and doesn't bother with instances of model objects - only their types. The mapping would essentially describe to the UI how to treat an object of a particular type. I would perhaps use a static member in each model class (or somewhere else logical) specifying which UI actions can be performed on it (perhaps a vector of strings?), which would be read by the UI and used to generate the menu data (by the UI). In this way, a model class only needs to know what can be done to it, and the UI worries about actually doing those things.[/quote] That is good, but how do i use an object's <i>type</i> in C++? It's use of RTTI is quite limited. Qt has more powerful extensions, but i'm not sure if that will do what i want. I can create different dialogs which map to a model type, but each one would then have to dynamic_cast the model object from it's super type since i keep a single list of these objects. [quote name='Oberon_Command' timestamp='1295201782' post='4759705'] [quote]Does anyone have an idea of what Object Oriented design patterns to use here?[/quote] I would argue that thinking about this in terms of "what design pattern should I use?" isn't going to help you very much. Just solve the problem, think about what pattern you used later. Design patterns are descriptive, not prescriptive.[/quote] True, but my mind right now is a big blob. I need to structure my thoughts and wrap my head around how i am going to do it. I thought design patterns might help with that, it would give me something to build on.
  7. What about the property pages? It uses HTML to display the data in a table, and the code to build that table is currently being done in the UI class. But now that i want specifics for each subclass, where should this code go? Like the menu problem, the model classes shouldn't be responsible for creating data for the UI. But i need to utilise polymorphism so the dialog can be used for all model objects yet display specific data.
  8. I am writing a C++ application where i have an object model and a UI (as most applications do). For the model, i have a main object and a number of specialised subclasses. The UI has context menus and property dialogs that i want to be specific to each object type. The main object has a number of actions that are available in the menu, but the subclasses need to add menu items (actions). And similarly for the property dialog - it needs to display data specific to each subclass. My question is what is a good way to design this? I can put all the menu creation code in each class, so that the specialised classes override the function to give their own menus. Like this (pseudo-code): [code] class MainObject { virtual MenuList getMenus() { return Menu("do something"), Menu("do something else"), Menu("do a third thing"), } }; class SpecialObjectA : public MainObject { virtual MenuList getMenus() { return MainObject::getMenus() + Menu("special menu A"); } }; class SpecialObjectB : public MainObject { virtual MenuList getMenus() { return MainObject::getMenus() + Menu("special menu B"); } }; [/code] But that seems like the model classes are doing too much. They shouldn't be responsible for creating and managing UI objects. So maybe i could create a separate object hierarchy for creating the menus. Each class would be responsible for creating the menu for it's respective model object. Something like this: [code] class MainMenuController { MainObject* theObject; virtual MenuList getMenus() { return Menu("do something"), Menu("do something else"), Menu("do a third thing"), } }; class SpecialMenuControllerA : public MainMenuController { SpecialObjectA* theObject; virtual MenuList getMenus() { return MainObject::getMenus() + Menu("special menu A"); } }; class SpecialMenuControllerB : public MainMenuController { SpecialObjectB* theObject; virtual MenuList getMenus() { return MainObject::getMenus() + Menu("special menu B"); } }; class MainObject { virtual MenuList getMenus() { return new MainMenuController()->getMenus(); } }; class SpecialObjectA : public MainObject { virtual MenuList getMenus() { return new SpecialMenuControllerA()->getMenus(); } }; class SpecialObjectB : public MainObject { virtual MenuList getMenus() { return new SpecialMenuControllerB()->getMenus(); } }; [/code] But then i'm not sure where the logic for performing each menu action should go. Since each action operates on the model object, those MenuController classes above would need to know what object the action is for. I am using Qt, so i could use their powerful signals and slots mechanism to do this, but i'm not quite sure how. Does anyone have an idea of what Object Oriented design patterns to use here? I can provide more detail if my problem is unclear. thanks
  9. How to merge separate files with SVN?

    If you need a comparison tool, you can't go past Beyond Compare
  10. Hi, i have an installer for my application which is built using Inno Setup. I want to support multiple languages using the installer to allow the user to choose the language. My app uses a lot of common files for any language, but for some files - such as the string resources, help files, etc - there will be these files for each language. I want the installer to contain all these files. Then when the user has selected a language, it will install whatever it needs and then somehow only install the language specific files. The destination for these files will always be the same, but the source files that get copied will be different (i.e. depending on the language). I do not know how to do this. I found out that i can set ShowLanguageDialog to show a page in installation that lets you choose the language. And i know you can set the installer's language in the [Language] section. So that's one step done. Now all i need to do is somehow conditionally install files based on the selected language. So for, say, help files, the installer will contain the files for all languages that my app is translated in. These will be in source folders named after the lang id (e.g. Polish is \pl_PL\help). But the installer should just install it to a help directory in the program folders directory. I can use the {language} to do the opposite, i.e. to install it in a folder whose name is the lang id. But i do not want to do that because then my app will need conditional logic to find the directory. One other way i could do this is to install in different destination directories based on what lang is selected. So, for example, if Polish is selected, the help files will be installed in "(MyAppsInstallDir)\help\pl_PL\the files.html". But the problem with this is that i need to write additional code in my app to find those files, rather than just hard-coding a (relative) path to them.
  11. I think what MaulingMonkey means is that your loop that "does not get the threads" is probably being optimised away so that it doesn't even get run. I assume your test code looks something like this: // Getting threads get time for (...) { call Thread32Next } get time calculate time difference // Not getting threads get time for (...) { // do nothing } get time calculate time difference If that is the case, then the first loop will just run as fast as it can, using 100% CPU. And the second loop will be optimised away so that it doesn't even run. If that is not the case, then your code could probably be optimised, because i doubt that a single function call could use that much CPU. And you should post your code so that we know what you are talking about without having to guess.
  12. When i started making my application, i looked at wxWidgets and Qt. Qt won hands-down. It's more than just a GUI toolkit, it's a full application framework, and it makes creating both GUIs and application back-end a lot easier.
  13. Quote:Original post by gretty Something funny is happening though, I want to make any white pixel on my window transparent but any other pixels still show. So what should happen is that the text which is black should be shown but the white background will be transparent. But what happens is just the whole window is just transparent & the text is not shown? Like i said before, SetLayeredWindowAttributes doesn't work like that. It is only useful if you want to make your whole window transparent (or semi-transparent). You could continue with the WM_PAINT method, you just need to subclass your Static control rather than (or more correctly: as well as) your main window. This will allow you to "override" the WM_PAINT event of the Static control and draw the text the way you want. Or there might be easier ways to do it.
  14. 2.5D gamedev?

    Quote:Original post by nGamer6 i saw games made in both of them they aren't really that cool or is that the people who don't know how to code games with SDL / SMFL? The quality of the game only says something about the person who wrote the game, it doesn't say anything about the engine or library they are using. Hell, you could write a great game from scratch without any engine or library, it would just take a lot more time and skill