• What do you need help with? Version 5
    5,752 replies, posted
[QUOTE=Two-Bit;39091846]Hello gentlemen, Being new to C++ I ma having some trouble with switch statements. I am in the process of making a tic tac toe game (very basic). I have the user input an x and a y coordinate (for instance tc is top centre, br, bottom right). I am using switch statements to resolve the answer but I am not sure if I am using them correctly, it is also my first attempt at using functions so I have most likely misunderstood how they work. Apologise for the noob and probably poorly written code but if you wish to help me out here is. [url]http://pastebin.com/DzsaXskm[/url] Thank you very much ^.^[/QUOTE] A few things: * The variables that represent the places in the board are local to the function Board(), they will be generated every time the function is run (And if the function worked it would generate a new, blank board every time), and cannot be accessed outside of the function. Your switch statement can't access them, they should be on the global scope (Outside of all functions). * Board() is declared as returning a string, but it doesn't return anything, so it should be void. * place1() is declared as returning an integer, but it also doesn't return anything, so it should be void * that while() loop needs to be something like: [CPP] while(test) //No semicolon! { //...code } [/CPP] * Switch can only be used with integers in the parentheses (char, short, int, long, long long). The statement might check out on [I]some[/I] compilers, because strings are also technically integers in a way you really don't need to understand right now. You need to use a series of if...else statements.
Working with lwjgl on a doom style dungeon crawler. I have moved the main rendering game viewport up a bit, leaving space at the bottom for the HUD to be rendered and the game will be rendered above that ( its an 800x600 window ). To do this I used glViewport after I set up all the perspective view stuff in the initialization. Now how do I set up a seperate rendering loop and coordinate system and stuff for that area down in the bottom now? I want to have an orthographic thing going on so I can draw my HUD.
Is there any comprehensive guide to programming games. I don't quite understand how to communicate between classes in a good way. I also don't get how I would best implement menu screens, popups, overlays, or anything that is not just the bare game screen. Preferably in Java but I could work with a general guide.
If you're stuggeling with menus, try to make everything show up in the gamefield, eg. walk here to start, walk over there to see the options, etc.
[QUOTE=ryan1271;39097728]Is there any comprehensive guide to programming games. I don't quite understand how to communicate between classes in a good way. I also don't get how I would best implement menu screens, popups, overlays, or anything that is not just the bare game screen. Preferably in Java but I could work with a general guide.[/QUOTE] I always wondered the same thing. What I found out was that there is no "guide" for that stuff. You just learn it over time. Look at game sources, game examples, and follow tutorials. There really is no "correct" way to do things in game programming. There are efficient and non efficient ways. It is up to you to figure out which way works best for your current situation and go with it.
Learning game programming is learning (almost) everything there is. Start small. Write an addon for GMod, then a Source Engine mod. Slowly go up the ladder.
[QUOTE=Meatpuppet;39094315]You need to compile sfml 2.0 for vs11 using nmake. It won't work otherwise.[/QUOTE] For people disagreeing, I got the same error with using SFML 2.0 on VS12 and I had to recompile SFML for it, and that fixed it. I'm pretty sure SFML 2.0 only has 08 and 2010 compiled in the download. [editline]5th January 2013[/editline] [QUOTE=WeltEnSTurm;39098373]Learning game programming is learning (almost) everything there is. Start small. Write an addon for GMod, then a Source Engine mod. Slowly go up the ladder.[/QUOTE] I've always wondered, what does source engine coding entail? I've been curious, as I always thought when a mod leader was looking for a programmer, and since I'm comfortable with C, then I could probably learn it.
[QUOTE=Meatpuppet;39098650]I've always wondered, what does source engine coding entail? I've been curious, as I always thought when a mod leader was looking for a programmer, and since I'm comfortable with C, then I could probably learn it.[/QUOTE] Entities, game hooks (like CalcView for view alterations), weapons, gamemodes, UI, AI, and a lot more stuff.
[QUOTE=WeltEnSTurm;39098715]Entities, game hooks (like CalcView for view alterations), weapons, gamemodes, UI, AI, and a lot more stuff.[/QUOTE] Once I'm done with an SFML game I'm working on I might actually look into that; I've always wanted to work with a team and be a part of something; it also gives me some initiative to work. [editline]5th January 2013[/editline] Thanks!
Oh yeah, that is actually a great idea. I would start with a gmod gamemode and then make a source mod, that will get you on the correct path :)
[QUOTE=Duskling;39098905]Oh yeah, that is actually a great idea. I would start with a gmod gamemode and then make a source mod, that will get you on the correct path :)[/QUOTE] Haha, I can't map or model for shit though. I also don't know lua
[QUOTE=Meatpuppet;39098981]Haha, I can't map or model for shit though. I also don't know lua[/QUOTE] You can learn Lua in an afternoon pretty much. Just check out [url]http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index2bde.html[/url] and see what you think.
The first edition of [URL="http://www.lua.org/pil/"]PIL[/URL] is free and was a joy to read if you are interested in learning Lua. Might be overkill for just a bit of gmod Lua, but even if you don't use it the language is really interesting.
[QUOTE=A big fat ass;39088057]I'm very new to VB, and I want to make a program where the user can choose and replace one file on their system with another. I'm thinking of how to do it, and I'm having some trouble. I think a combo box would work great for selecting the files, but I'm having some difficulty in figuring out how to put variables in the combo box instead of just strings.[/QUOTE] In VB.NET this should be extremely easy. Code off the top of my head.. [code] Sub Button_click() Handles YourButton.Click Dim fileToReplace As String 'show the file dialog Dim ofd As New OpenFileDialog() 'picking file 1 If ofd.ShowDialog() = DialogResult.OK Then fileToReplace = ofd.FileName Else 'the user didn't pick a file, handle it Exit Sub 'make sure the ofd isn't shown again, and the sub doesn't continue End If 'picking file 2 If ofd.ShowDialog() = DialogResult.OK Then FileIO.FileSystem.WriteAllText(FileIO.SpecialDirectories.Temp & "\tempfile", FileIO.FileSystem.ReadAllText(ofd.FileName), False) 'in the above line, I copied one of the files were going to be replacing to a temp file, so we can access it later FileIO.FileSystem.WriteAllText(ofd.FileName, FileIO.FileSystem.ReadAllText(fileToReplace), False) 'Relace the file we just picked with the original file FileIO.FileSystem.WriteAllText(fileToReplace, FileIO.FileSystem.ReadAllText(FileIO.SpecialDirectories.Temp & "\tempfile"), False) Else 'the user didn't pick a file Exit Sub End If End Sub [/code] Tested and works perfectly. Preserves file names.
Lua Question! If I quickly assign something like: [lua] fStart = a,b,c [/lua] How can I come back later and compare the 2 value of fStart to something else: [lua] if b == fStart then end [/lua] The above function simply will compare the first value with 'b'. How do you compare the second and third value individually with out having to compare like: [lua] if a,b,c == fStart then end[/lua] Thanks in advance!
[QUOTE=otoris;39109268]Lua Question! If I quickly assign something like: [lua] fStart = a,b,c [/lua] How can I come back later and compare the 2 value of fStart to something else: [lua] if b == fStart then end [/lua] The above function simply will compare the first value with 'b'. How do you compare the second and third value individually with out having to compare like: [lua] if a,b,c == fStart then end[/lua] Thanks in advance![/QUOTE] It looks like you are confusing multiple assignment and tables. Multiple assignment: [lua]local a, b, c = 1, 2, 3 -- a = 1, b = 2, c = 3 local f = 4, 5, 6 -- f = 4. Note that 5 and 6 are discarded[/lua] Tables: [lua]local f = {a, b, c} if f[1] == a then -- f[2] = b, f[3] = c -- do something end[/lua] The elements of a table can be accessed with square brackets like above.
[QUOTE=MakeR;39109347]It looks like you are confusing multiple assignment and tables. Multiple assignment: [lua]local a, b, c = 1, 2, 3 -- a = 1, b = 2, c = 3 local f = 4, 5, 6 -- f = 4. Note that 5 and 6 are discarded[/lua] Tables: [lua]local f = {a, b, c} if f[1] == a then -- f[2] = b, f[3] = c -- do something end[/lua] The elements of a table can be accessed with square brackets like above.[/QUOTE] Whoa... Didn't notice it discarding 5 and 6 at all... Tables it is! Thanks for the clarity.
I'm having trouble setting up GLFW on Visual Studio 10.0 I was following [url=http://www.gamedev.net/topic/316102-glfw-linking-problems/]this guys[/url] tutorial. However I am still getting linking errors [code]1>GLFW.lib(window.obj) : error LNK2005: __glfwClearWindowHints already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwClearInput already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwInputKey already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwInputChar already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwInputMouseClick already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwChooseFBConfig already defined in window.obj 1>GLFW.lib(window.obj) : error LNK2005: __glfwInputDeactivation already defined in window.obj 1>GLFW.lib(init.obj) : error LNK2005: __glfwInitialized already defined in init.obj 1>GLFW.lib(glext.obj) : error LNK2005: __glfwParseGLVersion already defined in glext.obj 1>GLFW.lib(glext.obj) : error LNK2005: __glfwStringInExtensionString already defined in glext.obj 1>GLFW.lib(glext.obj) : error LNK2005: __glfwRefreshContextParams already defined in glext.obj 1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library[/code] I have tried googling the errors but I havent found much help. I have linked opengl32/lib and glu32.lib in the linker settings. Help?
Im trying to add in animations for ironsights which is triggered by a button for my mod. Ive already defined and added the buttons and so on, but now I am just trying to trigger animations to play when the button is pressed. This is what I have in basecombatweapon_shared.cpp under void CBaseCombatWeapon::ItemPost [CPP] if ( pOwner->m_nButtons & IN_IRONSIGHT ) { IronSight(); if ( !bIronsighted && (pOwner->m_nButtons & IN_IRONSIGHT ) ) { bIronsighted = true; SendWeaponAnim( ACT_VM_IRON_IDLE ); m_fIronsightedReady = gpGlobals->curtime + GetViewModelSequenceDuration(); } else if ( bIronsighted && !(pOwner->m_nButtons & IN_IRONSIGHT ) ) { bIronsighted = false; SendWeaponAnim( ACT_VM_IDLE ); m_fIronsightedReady = gpGlobals->curtime + GetViewModelSequenceDuration(); } if ( bIronsighted ) { if ( gpGlobals->curtime > m_fIronsightedReady ) { bIronsighted = true; SendWeaponAnim( ACT_VM_IRON_IDLE ); m_fIronsightedReady = gpGlobals->curtime + GetViewModelSequenceDuration(); } return; } else if ( bIronsighted ) { if ( gpGlobals->curtime > m_fIronsightedReady ) { bIronsighted = false; SendWeaponAnim( ACT_VM_IDLE ); m_fIronsightedReady = gpGlobals->curtime + GetViewModelSequenceDuration(); } return; } }[/CPP] But it doesnt do anything, any help?
That might be the worst ironsight implementation I've seen yet (also editing base classes... yuck). The reason it won't do anything (or might jitter) is because it will then attempt to play the idle animation. Check the relevant code for where the idle animation is set.
[QUOTE=SteveUK;39111833]That might be the worst ironsight implementation I've seen yet (also editing base classes... yuck). The reason it won't do anything (or might jitter) is because it will then attempt to play the idle animation. Check the relevant code for where the idle animation is set.[/QUOTE] Ill be honest with you, I have no idea how to program.
So I'm trying to implement real-time events into a game I'm working on... What is the best way to track time in Java, and execute events occasionally? (Such as weather change, etc) Right now I've got a clock working with the Java Date class and I update it after a change between System.CurrentTimeMillis(), but is there a better way? Thanks
[QUOTE=Elv02;39119599]So I'm trying to implement real-time events into a game I'm working on... What is the best way to track time in Java, and execute events occasionally? (Such as weather change, etc) Right now I've got a clock working with the Java Date class and I update it after a change between System.CurrentTimeMillis(), but is there a better way? Thanks[/QUOTE] Create a thread then make it sleep for however long you need, [url]http://stackoverflow.com/questions/2702980/java-loop-every-minute[/url]
[QUOTE=sambooo;39120408]Create a thread then make it sleep for however long you need, [url]http://stackoverflow.com/questions/2702980/java-loop-every-minute[/url][/QUOTE] I get that, but what if, say, I wanted an event to happen at 2PM, and the user exited the program at 1:50? I guess I would just save the date on program close and do a comparison to that when it opens? I... think I just answered my own question... Thanks :P On a new note, are there any good articles on object serialization you guys can recommend?
[QUOTE=Elv02;39120619]I get that, but what if, say, I wanted an event to happen at 2PM, and the user exited the program at 1:50? I guess I would just save the date on program close and do a comparison to that when it opens? I... think I just answered my own question... Thanks :P On a new note, are there any good articles on object serialization you guys can recommend?[/QUOTE] [URL="http://en.wikipedia.org/wiki/Rubber_duck_debugging"]And you just performed this![/URL]
I need to find out, specifically, the formula for Mario's Fireball bounces. When they hit a level surface, it's only 45° that it bounces at. If the surface, itself, is at an angle, it bounces at an angle that is slightly higher than the angle of the surface (by about 5° to 15°). What I need to know, is how to figure out the correct displacement. On level surfaces, the most it can bounce to is 90° additions to a 45° turn. I shouldn't need trigonometry to figure this out. All I should need is the surface normal, and arithmetic. :v:
Okay so I've built several GUI applications in Java now and I really want to transition into making some Android applications. I have this book [URL="http://www.amazon.com/Hello-Android-Introducing-Development-Programmers/dp/1934356565/ref=sr_1_1?ie=UTF8&qid=1357503050&sr=8-1&keywords=Hello+Android"]"Hello Android"[/URL], should I just continue to read that? I just would like to know from some of your personal experiences what worked the best into starting Android development.
[QUOTE=W00tbeer1;39121147]Okay so I've built several GUI applications in Java now and I really want to transition into making some Android applications. I have this book [URL="http://www.amazon.com/Hello-Android-Introducing-Development-Programmers/dp/1934356565/ref=sr_1_1?ie=UTF8&qid=1357503050&sr=8-1&keywords=Hello+Android"]"Hello Android"[/URL], should I just continue to read that? I just would like to know from some of your personal experiences what worked the best into starting Android development.[/QUOTE] That book definitely isn't a bad place to start. Of course a lot of things (if not everything) you need to learn about programming can be found online, but sometimes it's nice to have a book to go through (in my opinion). And since you have it anyway, why not give it a read? If it doesn't work for you, then come back, (and maybe say what part of the book didn't work for you, that would help)
117! GO CHIEF! ... but, as I said earlier: (to be more... self-involved) [code]I need to find out, specifically, the formula for Mario's Fireball bounces. When they hit a level surface, it's only 45° that it bounces at. If the surface, itself, is at an angle, it bounces at an angle that is slightly higher than the angle of the surface (by about 5° to 15°). What I need to know, is how to figure out the correct displacement. On level surfaces, the most it can bounce to is 90° additions to a 45° turn. I shouldn't need trigonometry to figure this out. All I should need is the surface normal, and arithmetic. :v: [/code] [editline]January 16 2013[/editline] Easier to help with: Is physcollide data.HitNormal.z on a scale of 90? Such as this: 1.0=-90, 0.5=-45, 0=0, -0.5=45, -1.0=90 or 1 = Straight Up, 0 = Level to gravity, -1 = straight down. Or is it reversed. since -90° is UP, and +90° is DOWN in Source? Thus, -1 is up, and +1 is down... 0 is still level to gravity. [url]http://facepunch.com/showthread.php?t=1237765[/url]
I have a question, does Box2D support circle-collision? I've only seen people make boxes with it, and that's about it.
Sorry, you need to Log In to post a reply to this thread.