• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=WeltEnSTurm;39573942]Maybe C++ wasn't the right language for you then.[/QUOTE] Sorry but did we read the same post? He's having problems structuring code, switching languages doesn't mean you need to stop structuring your code (unless it's PHP! *snickers*)
There are more mistakes you can do in C++ than in other languages. He clearly is a beginner, and C++ is not the right language if he wants to learn programming AND about game engines. "Too hard to debug" doesn't have a lot to do with structuring alone.
[QUOTE=WeltEnSTurm;39577558]There are more mistakes you can do in C++ than in other languages. He clearly is a beginner, and C++ is not the right language if he wants to learn programming AND about game engines. "Too hard to debug" doesn't have a lot to do with structuring alone.[/QUOTE] C++ is fine for a beginner, if you put your work into it.
Not recommending C++ because "you can make more mistakes with it" is terrible advice. If you were trying to say not to recommend C++ to a beginner because it features more exposed memory management such as pointers, I MIGHT agree with you to an extent (for some beginners). But as a beginner, mistakes are meant to be learned from, not to be avoided and hidden away. If you'd prefer he go with a language that safe guards him from breaking stuff or not working, he won't learn a thing.
[QUOTE=WeltEnSTurm;39577558]There are more mistakes you can do in C++ than in other languages. He clearly is a beginner, and C++ is not the right language if he wants to learn programming AND about game engines. "Too hard to debug" doesn't have a lot to do with structuring alone.[/QUOTE] holy shit do you not understand that i'm not having ANY problems with the language itself, but problems with the structuring of a project i'll try to make myself understand and able to implement state-driven engines anyone have any examples that I can learn from?
I want to embed Lua into my game. I am getting it to work, but was wondering how I can use Lua with my weapons so that the onFire function is fully scriptable. I was thinking of making that function just a pointer to a function defined in the Lua files, but am having trouble reading files in Lua. This is using Luabind. Right now, I imported my weapons class, and a class called session which basically stores all the weapon and ammo information. This code, however, is crashing on me (or, more importantly, the for loop line). What's the issue? It doesn't even work if I strip everything inside it. [code]weaponNames = {pistol} function load(session) session:test() loadWeapons(session) end function loadWeapons(session) for i in weaponNames do dofile(i..".lua"); local weapon(modifier, firespeed) weapon:setOnFire(onFire) session.addWeapon(i, weapon) session.setWeaponAmmo(i, ammo); end end[/code]
[QUOTE=Meatpuppet;39579524]holy shit do you not understand that i'm not having ANY problems with the language itself, but problems with the structuring of a project i'll try to make myself understand and able to implement state-driven engines anyone have any examples that I can learn from?[/QUOTE] [code] class State { virtual void Input() = 0; virtual void Logic() = 0; virtual void Draw() = 0; public: virtual bool Run() { Input(); Logic(); Draw(); return true; } }; class MainMenuState : public State { void Input(); void Logic(); void Draw(); public: }; class GameplayState : public State { void Input(); void Logic(); void Draw(); public: }; class StateMachine { std::vector< State * > m_vStates; //Vector of all state instances. public: void AddState( State * ); State * GetState( int ); }; int main( int argc, char ** argv ) { //Init code.. State * pCurState = stateMachine->GetState( 0 ); //main loop while( pCurState->Run() ) { } return 0; } [/code] Having trouble debugging? It helps to localize problematic code to one object or class rather than spread it out through your game engine because of poor design decisions
[b]IGNORE THIS![/b] Figured out why. I never actually checked that the room is valid. I forgot that I re-arranged how the methods call, to give me the ability to override rooms if need be. Just me being derpy. :v: ----- Building the room generator for my Dungeon Crawler I am building in Love 2D. My "boxes are not intersecting" code isn't quite working. Gray boxes are unexplored (the new box). Dark orange boxes have already been visited. Bright orange box is the active box. Clicking on a box generates new adjacent, unexplored rooms. As you can see, this new box is clipping quite clearly into the previous box (and indeed, there are other clipping boxes as well). [t]http://filesmelt.com/dl/BoxIntersection_001.jpg[/t] The code I am using, with the code I adapted commented out above it. [lua]--[[ function BoxesConflict(a,b) if (a.max.x <= b.min.x) then return false end; -- a is left of b if (a.min.x >= b.max.x) then return false end; -- a is right of b if (a.max.y <= b.min.y) then return false end; -- a is above b if (a.min.y >= b.max.y) then return false end; -- a is below b return true; -- boxes overlap end function CanCreateRoom(x,y,w,h) local a = {} a.max = {} a.min = {} a.max.x = x+w a.max.y = y+h a.min.x = x a.min.y = y local b = {} b.max = {} b.min = {} for k,v in pairs(TEMP_DUNGEON_STATE.Rooms) do b.max.x = v.Position[1]+v.Dimension[1] b.max.y = v.Position[2]+v.Dimension[2] b.min.x = v.Position[1] b.min.y = v.Position[2] if BoxesConflict(a,b) then return false end end return true end ]] function CanCreateRoom(x,y,w,h) for k,room in pairs(TEMP_DUNGEON_STATE.Rooms) do if (not (((x+w) <= (room.Position[1])) or (x >= (room.Position[1]+room.Dimension[1])) or ((y+h) <= (room.Position[2])) or (y >= (room.Position[2] + room.Dimension[2])))) then return false end end return true end[/lua] The commented-out code does not work either. What's strange is, when generating boxes that are only adjacent to the first room, the code works beautifully. No two boxes that are adjacent to the same box will clip. But when it gets to boxes adjacent to boxes that are not adjacent themselves, all bets are off. And I don't know why. When a room is created, it is automatically added into DUNGEON_TEMP_STATE.Rooms. [editline]fish[/editline] [b]IGNORE THIS![/b] Figured out why. I never actually checked that the room is valid. I forgot that I re-arranged how the methods call, to give me the ability to override rooms if need be. Just me being derpy. :v:
[QUOTE=WTF Nuke;39581856]I want to embed Lua into my game. I am getting it to work, but was wondering how I can use Lua with my weapons so that the onFire function is fully scriptable. I was thinking of making that function just a pointer to a function defined in the Lua files, but am having trouble reading files in Lua. This is using Luabind. Right now, I imported my weapons class, and a class called session which basically stores all the weapon and ammo information. This code, however, is crashing on me (or, more importantly, the for loop line). What's the issue? It doesn't even work if I strip everything inside it. [code]weaponNames = {pistol} function load(session) session:test() loadWeapons(session) end function loadWeapons(session) for i in weaponNames do dofile(i..".lua"); local weapon(modifier, firespeed) weapon:setOnFire(onFire) session.addWeapon(i, weapon) session.setWeaponAmmo(i, ammo); end end[/code][/QUOTE] The for loop line contains an error because you are using the for in syntax incorrectly (see [url=http://www.lua.org/manual/5.1/manual.html#2.4.5]this[/url], specifically the part about the generic for loops). Also, the 11th line isn't valid Lua (function call preceded by the local keyword) and the weapon local variable is never being set to anything and, therefore, can not be indexed on the next line.
-snip- wrong thread
[QUOTE=marvinelo;39586826]So, I'm currently writing a bot for a forum and I have no idea how to parse php information via HTTP. I want to login via this link [B]"http://www.someforum.com/forum/index.php?action=login"[/B] and somehow have to use the following information: [B]"user=User+Name&passwrd=Password&openid_identifier=&cookieneverexp=on&hash_passwrd=Passwordhash"[/B]. Though, I have no idea how to exactly parse this. Things like [B]"http://www.someforum.com/forum/index.php?action=login&user=User+Name&passwrd=Password&openid_identifier=&cookieneverexp=on&hash_passwrd=Passwordhash" [/B] don't seem to work. Of course I used my real account info and the correct password hash when I was trying use this link.[/QUOTE] [url]http://facepunch.com/showthread.php?t=1152061[/url]
[QUOTE=WeltEnSTurm;39577558]There are more mistakes you can do in C++ than in other languages. He clearly is a beginner, and C++ is not the right language if he wants to learn programming AND about game engines. "Too hard to debug" doesn't have a lot to do with structuring alone.[/QUOTE] He never said anything about the language being hard, and yes, "too hard to debug" can definitely have everything to do with the structure of the code. Part of the benefits of a good code structure is it makes debugging easier. I don't know if you're bad with C++ or not, but please don't assume everyone else will have the same problems especially when they explicitly state what the real issue is (code structure).
I find myself struggle a bit with learning path-finding, not the straight across the screen walk, but I was trying to implement the star-path-finding system and it ended up with hours of code so messed up that I had basically painted myself into a corner. It was a creation of perfection in the arts of making loops upon loops upon functions upon functions in the manner that, if I removed some of the code it would be too difficult, and if I added more it would just add to the pain. I removed the code and have never tried again. Frustration has a way of changing your thought patterns. Though I wish this knowledge to be mine, would anyone be kind enough to provide with perhaps some advice and maybe theoretical code. Just don't solve it for me, the human brain adapts better to a problem when itself procures the answer.
[QUOTE=Memnoth;39589083]I find myself struggle a bit with learning path-finding, not the straight across the screen walk, but I was trying to implement the star-path-finding system and it ended up with hours of code so messed up that I had basically painted myself into a corner. It was a creation of perfection in the arts of making loops upon loops upon functions upon functions in the manner that, if I removed some of the code it would be too difficult, and if I added more it would just add to the pain. I removed the code and have never tried again. Frustration has a way of changing your thought patterns. Though I wish this knowledge to be mine, would anyone be kind enough to provide with perhaps some advice and maybe theoretical code. Just don't solve it for me, the human brain adapts better to a problem when itself procures the answer.[/QUOTE] I recommend learning [url=https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm]Dijkstra's algorithm[/url] first. A* is based on it (and optimized for realtime calculations) and in my opinion is easier to understand. It wasn't until I was taught Dijkstra's algorithm in high school that I truly grasped how A* works, despite having implemented a working (but slow and buggy) version of it earlier. Oh and don't look up how to do it in code or something like that. Learn how it works by doing it manually on paper. And don't forget to plan how the structure of your A* implementation should be before you write any code.
Ugh... I just don't feel like starting over. I had been working almost daily on that fucked up project. I need new ideas for something other than a 2D game engine. Or a challenge. Anyone have any challenges for me to get me back in the programming mood?
[QUOTE=Meatpuppet;39592078]Ugh... I just don't feel like starting over. I had been working almost daily on that fucked up project. I need new ideas for something other than a 2D game engine. Or a challenge. Anyone have any challenges for me to get me back in the programming mood?[/QUOTE] Make a simulation of crowd movement in a square and have the ability to turn one of them into a thief, and program it with hilarity, brutality or even both. Study what makes games engaging, maybe try to make something that's not supposed to be violent or competitive. Program something that makes people ask you "why?", and you respond, "Because I can." [url]http://www.penny-arcade.com/patv/show/extra-credits[/url] Watch their show, they talk about how games are a medium that's supposed to make us explore all kinds of different experiences.
Alright guys, any opinions on BLAS libraries? I'm leaning towards the Intel (It's for an Ivy based number cruncher) offerings (Math Kernel Library) but I'm curious if any of you have any favourites? Use case is high performance computing, large matrice stuff for systems biology, that kind of thing. Already using CUDA's offerings, looking for something to compliment it in standard code. EDIT- Oh, shit, ideally C/C++ but I've no qualms jumping to Ada, Fortran or the like if the results are worth it.
[QUOTE=Memnoth;39592485]Make a simulation of crowd movement in a square and have the ability to turn one of them into a thief, and program it with hilarity, brutality or even both. Study what makes games engaging, maybe try to make something that's not supposed to be violent or competitive. Program something that makes people ask you "why?", and you respond, "Because I can." [url]http://www.penny-arcade.com/patv/show/extra-credits[/url] Watch their show, they talk about how games are a medium that's supposed to make us explore all kinds of different experiences.[/QUOTE] That seems like a good idea; seems simple, too, with SFML and C++. Thanks!
Not sure if anyone here could help me with this, it uses middleclass. I'm learning Lua/LOVE at the moment and I'm having issues with this. [CODE] require "middleClass" require "debugText" MapCollision = class('MapCollision') function MapCollision:Initialize(gravx,gravy) Log("MapCollision initializing HURRAH!") world = love.physics.newWorld(gravx, gravy, true) for i=1, i == 2 do -- change this later self.CollisionBox = {} self.CollisionBox[i].Body = love.physics.newBody(world,200,200,50,0)-- change these too self.CollisionBox[i].Shape = love.physics.newRectangleShape(self.CollisionBox[i].Body,200,200,50,50) self.CollisionBox[i].Fixture = love.physics.newFixture(self.CollisionBox[i].Body,self.CollisionBox[i].Shape) end Log("MapCollision initialized") end function MapCollision:UpdateWorld(dt) if self.world ~= nil then self.world:update(dt) end end function MapCollision:DebugDraw() love.graphics.setColor(200, 40, 20) for i=1,2 do if CollisionBox ~= nil then love.graphics.polygon("line", self.CollisionBox[i].Body:getWorldPoints(self.CollisionBox[i].Shape:getPoints())) else --Log("DebugDraw Still Nil") end end end [/CODE] The class doesn't initialize even though it is being called in main.lua
[QUOTE=MakeR;39584501]The for loop line contains an error because you are using the for in syntax incorrectly (see [url=http://www.lua.org/manual/5.1/manual.html#2.4.5]this[/url], specifically the part about the generic for loops). Also, the 11th line isn't valid Lua (function call preceded by the local keyword) and the weapon local variable is never being set to anything and, therefore, can not be indexed on the next line.[/QUOTE] I realized all these errors post-post, but thanks anyway!
[QUOTE=reevezy67;39595286]Not sure if anyone here could help me with this, it uses middleclass. I'm learning Lua/LOVE at the moment and I'm having issues with this. [CODE] require "middleClass" require "debugText" MapCollision = class('MapCollision') function MapCollision:Initialize(gravx,gravy) Log("MapCollision initializing HURRAH!") world = love.physics.newWorld(gravx, gravy, true) for i=1, i == 2 do -- change this later self.CollisionBox = {} self.CollisionBox[i].Body = love.physics.newBody(world,200,200,50,0)-- change these too self.CollisionBox[i].Shape = love.physics.newRectangleShape(self.CollisionBox[i].Body,200,200,50,50) self.CollisionBox[i].Fixture = love.physics.newFixture(self.CollisionBox[i].Body,self.CollisionBox[i].Shape) end Log("MapCollision initialized") end function MapCollision:UpdateWorld(dt) if self.world ~= nil then self.world:update(dt) end end function MapCollision:DebugDraw() love.graphics.setColor(200, 40, 20) for i=1,2 do if CollisionBox ~= nil then love.graphics.polygon("line", self.CollisionBox[i].Body:getWorldPoints(self.CollisionBox[i].Shape:getPoints())) else --Log("DebugDraw Still Nil") end end end [/CODE] The class doesn't initialize even though it is being called in main.lua[/QUOTE] This is wrong (essentially your upper limit is a boolean value): [code]for i=1, i == 2 do[/code] In the DebugDraw function, CollisionBox should be self.CollisionBox.
Missed that, thanks. [editline]15th February 2013[/editline] The class isn't even initializing for some reason. [editline]15th February 2013[/editline] AHA! Capital I on the initialize function.
Python question. [code]if True == (False or True): print "test 1" if 1 == (2 or 1): print "test 2"[/code] Why does only test 1 print here, and not test 2, but with: [code]if True == (False or True): print "test 1" if 1 == (1 or 2): print "test 2"[/code] Both print?
[QUOTE=Zally13;39596613]Python question.[/QUOTE] I imagine (1 or 2) evaluates to 1 and (2 or 1) evaluates to 2 due to 2 being treated as True. But (False or True) will evaluate to True as the or operator is going to check True after realising False isn't true.. I can't explain this too well. Here's yer proof: [url]http://codepad.org/iOsbqFvl[/url]
[QUOTE=Willox;39596629]I imagine (1 or 2) evaluates to 1 and (2 or 1) evaluates to 2 due to 2 being treated as True. But (False or True) will evaluate to True as the or operator is going to check True after realising False isn't true.. I can't explain this too well. Here's yer proof: [url]http://codepad.org/iOsbqFvl[/url][/QUOTE] If it evaluated 2 as True wouldn't it still print both regardless?
[QUOTE=Zally13;39596651]If it evaluated 2 as True wouldn't it still print both regardless?[/QUOTE] Sorry, I meant that the OR operator is going to give 2 back as it isn't treated as false - not strictly treating it as true.
[QUOTE=Willox;39596657]Sorry, I meant that the OR operator is going to give 2 back as it isn't treated as false - not strictly treating it as true.[/QUOTE] That makes sense.
-snip- I'm an idiot. [editline]16th February 2013[/editline] Loading a map on love.update..
-snip- [editline]15th February 2013[/editline] learn to read, ezhik, learn to read... [editline]15th February 2013[/editline] okay different question (LOVE): [php]function love.load() love.graphics.setBackgroundColor (135, 206, 235) love.physics.setMeter(64) world = love.physics.newWorld(0, 9.81*64, true) objects = {} --ground objects.ground = {} objects.ground.body = love.physics.newBody(world, 800/2, 650-50/2) --defined from the middle objects.ground.shape = love.physics.newRectangleShape(650,50) objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape) end function love.draw() --to show the "ground" shape love.graphics.setColor(72,160,14) --THIS BETTER BE GREEN love.graphics.polygon("fill", objects.ground.body:getWorldPoints(objects.ground.shape:getPoints())) love.graphics.setColor(200, 14, 47) if isBlockM then love.graphics.polygon("fill", objects.blockM.body:getWorldPoints(objects.blockM.shape:getPoints())) end if love.mouse.isDown("l") then love.graphics.rectangle("line", x1, y1, love.mouse.getX() - x1, love.mouse.getY() - y1) end end function love.update( dt ) world:update(dt) --so that stuff moves end function love.mousepressed( x, y, button ) --print("Mouse pressed: " .. x .. ", " .. y .. "; Button: " .. button) x1 = x y1 = y end function love.mousereleased( x, y, button ) x2 = x y2 = y print("x1 = " .. x1 .. "; y1 = " .. y1 .. "; x2 = " .. x2 .. "; y2 = " .. y2) shapeX = (x1 + x2)/2 shapeY = (y1 + y2)/2 shapeW = x2 - x1 shapeH = y2 - y1 objects.blockM = {} objects.blockM.body = love.physics.newBody(world, shapeX, shapeY, "dynamic") objects.blockM.shape = love.physics.newRectangleShape(0, 0, shapeW, shapeH) objects.blockM.fixture = love.physics.newFixture(objects.blockM.body, objects.blockM.shape, 2) --that 5 is density isBlockM = true end[/php] how would i go around making every shape created with my mouse rendered? what i have now only shows the latest shape - although all other shapes are still there, so if i make a new box on top of an older one, it'll appear to float in midair
Alright, I'm really not that good with code, but since I'm only editing a source file and recompiling it I think I'm doing fine. Basically it's going to launch a game and trick Steam into thinking I'm using Linux instead of Windows. Here's the source code I'm compiling, C# in Visual Studio: [code] using System; using System.Collections.Generic; using System.Linq; using System.Text; using SteamKit2; using System.Net; using SteamKit2.Internal; using System.Threading; namespace tf2get { class Program { static SteamClient client; static CallbackManager manager; static SteamUser user; static SteamFriends friends; static string username, password, authCode; static void Main( string[] args ) { client = new SteamClient(); manager = new CallbackManager( client ); user = client.GetHandler<SteamUser>(); friends = client.GetHandler<SteamFriends>(); new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager ); new Callback<SteamClient.ConnectedCallback>( OnConnected, manager ); new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, manager ); new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager ); Console.WriteLine( "Connecting to Steam..." ); client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() ); while ( true ) { manager.RunWaitCallbacks(); } } static void OnDisconnected( SteamClient.DisconnectedCallback callback ) { Console.WriteLine( "Disconnected from Steam, reconnecting in 5..." ); Thread.Sleep( TimeSpan.FromSeconds( 5 ) ); client.Connect( Dns.GetHostAddresses( "cm0.steampowered.com" ).FirstOrDefault() ); } static void OnConnected( SteamClient.ConnectedCallback callback ) { if ( callback.Result != EResult.OK ) { Console.WriteLine( "Unable to connect to Steam: {0}", callback.Result ); return; } Console.WriteLine( "Connected!" ); if ( string.IsNullOrEmpty( username ) ) { Console.Write( "Username: " ); username = Console.ReadLine(); } if ( string.IsNullOrEmpty( password ) ) { Console.Write( "Password: " ); password = Console.ReadLine(); } user.LogOn( new SteamUser.LogOnDetails { Username = username, Password = password, AuthCode = authCode, OSOverride = EOSType.Linux24, } ); } static void OnLoggedOff( SteamUser.LoggedOffCallback callback ) { Console.WriteLine( "Logged off of Steam: {0}", callback.Result ); } static void OnLoggedOn( SteamUser.LoggedOnCallback callback ) { if ( callback.Result == EResult.AccountLogonDenied ) { Console.WriteLine( "SteamGuard authcode required!" ); Console.Write( "Auth code: " ); authCode = Console.ReadLine(); return; } if ( callback.Result != EResult.OK ) { Console.WriteLine( "Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult ); return; } Console.WriteLine( "Logged onto Steam, launching game..." ); var clientMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>( EMsg.ClientGamesPlayedNoDataBlob ); clientMsg.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed { game_id = 440, } ); client.Send( clientMsg ); Console.WriteLine( "Done!" ); } } } [/code] It uses a library called SteamKit2. I'm not too familiar with the library, so my question is regarding it. It's giving me an error here: [code] user.LogOn( new SteamUser.LogOnDetails { Username = username, Password = password, AuthCode = authCode, OSOverride = EOSType.Linux24, } ); } [/code] It's saying that LogOn requires a username and password to be set in 'details'. But they are. They're null strings, but I've got a code that catches that and then asks the user for input. What's wrong? Also, Does using this alongside Steam break the EULA given by Valve? I.e. does this risk an account ban? I've seen this library used for many things, and it's emulating commands I could do myself manually. I've tried asking elsewhere and they haven't got a clue. Sorry if this comes off as dumb.
Sorry, you need to Log In to post a reply to this thread.