• What do you need help with? Version 1
    5,001 replies, posted
[QUOTE=compwhizii;21995692]Does anyone have an OSX development experience? I'm planning around with Obj-C and I have a question, [img]http://grab.by/grabs/48a2a1cba0e0da9435ca1f0f3126c9b2.png[/img] What's that called and how do I create it. :downs: I think it's UIAlertView but I'm not entirely sure. [editline]10:22PM[/editline] UIAlertView is for cocoa touch.[/QUOTE] NSAlert.
[QUOTE=Whitewater;22017370]Googled 'APNG format' and clicked the first link... Found this [url]https://wiki.mozilla.org/APNG_Specification[/url] It appears it contains all of the information you could possibly need to make the program read and display all of the frames.[/QUOTE] I have seen that and have no idea how to use it.
[QUOTE=Chris122990;22017670]I have seen that and have no idea how to use it.[/QUOTE] That's a specification of the APNG format, providing you with enough information to be able to parse the file yourself. I'm not familiar with Java, but I assume there is some sort of class that can open a binary file and read from it?
Anyone got an replacement for the XACT sound library in XNA? XACT kinda sucks...
I haven't done any coding since, just before christmas really, and i'm bummed on this problem. [url]http://pastebin.com/T5CjFPwf[/url] I'm wanting it to go grab the source, save it to #Page.txt (where # incerements by one in the getFile function). The way it works is goes to this page; [url]http://wiki.garrysmod.com/index.php?title=Category:Lua_functions[/url] Saves the page source, then passes the source onto the getAllPages function which then finds the "next 200" link, and passes it onto the getFile to create a new page .txt file. Then repeat until pages < 4. But from my testing, 'pages' never seems to increment once. It keeps spewing out "Wrote page: 1" every iteration. [b]edit[/b] Fixed it, just had to move the iteration above the if statement. :love: ja_cop
Platforming. I just can't work it out. Basically, my game is completely tile-based, but I want to player to move smoothly through it, like in the Mario games. Any good articles? I have jumping and left+right movement; but I just can't work out how to do collisions.
What don't you get? If the player has entered the area of the block bellow it, it collided. If the player entered the block to the left or right, it collided. If you want to be able to jump through something, just don't check for collision above the player.
I understand the concept, that's the easy part. I'm just having so many problems when I get round to trying to implement it.
Image we have tiles 10x10 and our player is 5x10 in size. All tiles are placed on a 100x100 that can hold 100 tiles. They are stored in an array so that, if we want to access the tile at 0,0 , we do tilearray[0][0]. If we want to access the tile at 10, 0 , we do tilearray[1][0] because each tile it 10 pixels wide and 10 pixels high. Now, to check if the player is colliding with a tile first we take his coordinates, divide them by 10 and floor them (x1 = (int)(x/10), y1 = (int)(y/10)). That means that he is colliding with the tilearray[x1][y1] so everything that remains is to check if the tile is collidable, since it could just be a bush tile or something that you can go through. We do the same thing with (x+5, y) and (x, y+10) for right and bottom collision. If the player collided with something on the right, set it's x to the tile.x-5, if it collided with something on the left, set it's x to the tile.x+10. If it collided with something bellow him, set it's y to tile.y-10. I hope that was clear enough. I might try to do something like that soon so I can show you the code.
Ok, that lays it out a bit better for me, thanks :) Now, how do I check whether or not to apply acceleration under gravity? Because in previous attempts, it would move him down a bit, then realise he's colliding and move him up again. I was thinking of setting a flag, like "OnGround" to true, and if it is true then don't apply acceleration under gravity. But then I have to think about when to un-set that flag and so on.
What I'm currently doing is, increase speed.y by 1, check for collision, it it's colliding with something bellow, set speed.y to 0. Apply speed. The trick is that you don't check the tile that is at player.y+10 but player.y+11 so you don't have to fall a bit first before it collides.
I suppose that works, but then there's no acceleration. The way I have movement at the moment is with my Player object having a velocity vector. The Y component of the velocity gets incremented by gravity each frame, so you fall a lot more realistically
So? That's exactly what I'm doing. If you are colliding with something bellow you, set your vertical velocity to 0 (speed.y = 0)
Oh right yeah, I misread your post slightly. Sorry!
[QUOTE=Darwin226;22050550]So? That's exactly what I'm doing. If you are colliding with something bellow you, set your vertical velocity to 0 (speed.y = 0)[/QUOTE] Wouldn't the entity be stuck inside the entity below it, then? (just wondering, since i'm having trouble with it)
Now, setting speed.y to 0 isn't the only thing you do if it's colliding. Read post #818
I'm making a raytracer in C#, and when I click "Start" I want the picture to update on screen as each pixel gets calculated, I don't want to wait for the picture to just pop up at the end. I tried doing it with threads, but .Net throws a hissy fit when I try to do something with the image because I'm not doing it in the thread it was created in. How do I work around this?
[QUOTE=Sporbie;22084991]I'm making a raytracer in C#, and when I click "Start" I want the picture to update on screen as each pixel gets calculated, I don't want to wait for the picture to just pop up at the end. I tried doing it with threads, but .Net throws a hissy fit when I try to do something with the image because I'm not doing it in the thread it was created in. How do I work around this?[/QUOTE] [url]http://www.codeproject.com/KB/cs/winformthreading.aspx[/url]
I have a 'world' class that knows about all the entities in my asteroids game. My header: [cpp] #ifndef WORLD #define WORLD #include <SFML/System.hpp> #include <SFML/Graphics.hpp> #include "iostream" #include "cBaseEntity.hpp" #include "cAsteroid.hpp" #include "cShip.hpp" extern sf::Clock cur; class cWorld { private: sf::RenderWindow App; std::vector<cBaseEntity*> Entities; float fLastSpawnAsteroid; public: cWorld(); ~cWorld(); void Think(); void Draw(); void AddEntity(cBaseEntity *ent); sf::RenderWindow &GetApp() {return App;} }; #endif [/cpp] The problem is I want to be able to make my class "cShip" spawn bullets but to do that it needs to know about cWorld and the instance of that class called 'world' but I have no idea how to do that. I tried making world global and I keep getting a constant list of errors so I guess I am just taking the wrong approach to this. Here is how I try to spawn a bulllet in my ship class: [cpp] if (Input.IsMouseButtonDown(sf::Mouse::Button::Left)) { cBullet *ast = new cBullet; world.AddEntity(ast); } [/cpp] But it tells me world is not a valid class/struct/union. Whats the best way to organise a simple 2D engine? Currently it goes like: World knows about: cBaseEntity, cShip, cAsteroid, cBullet. All the classes that derive from the base entity include cBaseEntity.h cShip includes cBullet and cWorld but this is giving me errors. Sorry for the long post but its more about how to structure the code than the code itself.
-snip-
[QUOTE=conman420;22099542]I have a 'world' class that knows about all the entities in my asteroids game. My header: [cpp] #ifndef WORLD #define WORLD #include <SFML/System.hpp> #include <SFML/Graphics.hpp> #include "iostream" #include "cBaseEntity.hpp" #include "cAsteroid.hpp" #include "cShip.hpp" extern sf::Clock cur; class cWorld { private: sf::RenderWindow App; std::vector<cBaseEntity*> Entities; float fLastSpawnAsteroid; public: cWorld(); ~cWorld(); void Think(); void Draw(); void AddEntity(cBaseEntity *ent); sf::RenderWindow &GetApp() {return App;} }; #endif [/cpp] The problem is I want to be able to make my class "cShip" spawn bullets but to do that it needs to know about cWorld and the instance of that class called 'world' but I have no idea how to do that. I tried making world global and I keep getting a constant list of errors so I guess I am just taking the wrong approach to this. Here is how I try to spawn a bulllet in my ship class: [cpp] if (Input.IsMouseButtonDown(sf::Mouse::Button::Left)) { cBullet *ast = new cBullet; world.AddEntity(ast); } [/cpp] But it tells me world is not a valid class/struct/union. Whats the best way to organise a simple 2D engine? Currently it goes like: World knows about: cBaseEntity, cShip, cAsteroid, cBullet. All the classes that derive from the base entity include cBaseEntity.h cShip includes cBullet and cWorld but this is giving me errors. Sorry for the long post but its more about how to structure the code than the code itself.[/QUOTE] I don't think the ship should be spawning bullets. Maybe you should make the world class track user input and spawn bullets at the ships position and angle. Or try passing the world instance to the constructor of the ship and then use it when spawning bullets.
I am trying to make a system that loads settings from ini files. It's 100% done but i am getting a linker errors (shoot me) main.cpp [url]http://pastebin.com/xubidEz9[/url] test.h [url]http://pastebin.com/K9Q19rSV[/url] errors VS-Compiler [url]http://pastebin.com/NVBtd4LQ[/url] errors GCC-Compiler [url]http://pastebin.com/6Dc2itRK[/url]
[url]http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.11[/url] The code also looks lacking to me. For example the usage of atoi could be replaced with an std::stringstream, if the ini has indeed a value of "ERROR" - or when parsing for an int 0 - how would you know that this entry didn't exist? I'd use templates for parsing different types out of the ini/EVAR class. std::hash_map/std::unordered_map instead of two fixed-sized std::string arrays. Accessing stuff is way easier and using hashes way more efficient. And why are they static? The classname is pretty undescriptive. EVAR? huh? readsettings and writesettings should be memberfunctions. A function to just write specific entries might be useful as well. Your readsettings is pretty skippy. You should check for each '=' and read in the token left and right to it. Some entry like hurrdurr="Hello, world! This is a beautiful day!" would turn out as durr="Hello, world when parsed for hurr. And when parsed for durr it'd also take the entry of hurrdurr. You should maybe also check for duplicates.
First off all thank you for you help. Solved my problem Secondly i am aware that the code there is a mess. Since i am still learning C++. I will probably end up rewriting this code multiple times before i am satisfied. And if i din't i would probably end up in bumping in to the same problems you just mentioned. I am aware of the multiple ways of converting strings in to int's. I don't see wat is wrong with using atoi. Also the reason that some variables are non-descriptive as i don't like ending up with envroimentvariable.getvariable(something,something) The reason that they were static is so i could access them from every point in my program (don't ask why i used a class i already switched to a namespace) And once again thank for your advice/time/help -snip-
atoi doesn't do error-checking and if it cannot parse the value, then iirc the behavior is undefined by the C++ standard.
fair enough But now i am running in to a other problem if a use a hash_map (witch saves me a shitload of time) is there any way i can get my writesettings function to work. (other then keeping a list of member names in a array)
Yeah, loop through the members using iterators. [cpp]for(std::hash_map<std::string, std::string>::const_iterator iter = list.begin(); iter != list.end(); ++iter) file << iter->first << '=' << iter->second << '\n';[/cpp]
[code] namespace variable { std::map<string, string> variablelist; std::map<string, bool> convarlist; std::map<string, string> descriptionlist; void addvar(string name, string data, bool convarenabled, ...) { va_list Numbers; va_start(Numbers, convarenabled); variablelist[name] = data; convarlist[name] = convarenabled; if (convarenabled == true) { descriptionlist[name] = va_arg(Numbers, string); <-- This line } va_end(Numbers); } [/code] Gives a memory exception. BTW: dont tell me to make maps like map<string, string[3]> something; it wont work so i just use 3 maps And once again thanks for you time and help
va_arg() is a C function that doesn't know about proper copying of C++ objects, so it's not safe to use with std::string. It copies values byte-for-byte, rather than invoking a copy constructor. [QUOTE=ColdFusion;22121974]BTW: dont tell me to make maps like map<string, string[3]> something; it wont work so i just use 3 maps[/QUOTE] You could make a class or struct with three fields, two strings and a bool, and use that as the value type in a single map.
Don't use varargs for this. Use a default parameter or a function overload. You should also make a variable class and keep only a single map of instances of this class instead of those three maps.
Sorry, you need to Log In to post a reply to this thread.