• What do you need help with? Version 5
    5,752 replies, posted
snip i finally fixed something by myself :D
[CODE] if((leftc = getPing(9)) != 0) left = leftc; delay(15); if((frontc = getPing(10)) != 0) front = frontc; //get reading excluding bad readings of zero delay(15); //delay for cross-talk and time for interrupts to trigger if((rightc = getPing(11)) != 0) right = rightc; delay(15);[/CODE] Any idea why this code uses the c values if the regular names are the only ones used in the program? This is for an Arduino based AUV by the way, and the code isn't mine. Im polishing it up, some of their stuff is pants-on-head retarded
The following is Python if you couldn't tell. [code] def ss(nums): return sum(***2 for x in nums) [/code] How does this work and what is this called so I can learn it? I'm doing an Udacity class and apparently this is the same as: [code] def ss(nums): total = 0 for i in range(len(nums)): total = (total + nums[i]**2) return total [/code] which I totally understand, and if given the problem that is how I would have solved it, but I want to learn the top method because it seems very fast and efficient.
Just because something looks small and compact (syntactic sugar) doesn't mean it has to be fast and efficient. (I'm not saying that what you have there isn't, just that you should make such assumptions.)
I meant as writing code, since it's shorter, not the performance (which is likely the exact same or very close) [editline]22nd January 2013[/editline] to expand, there's also things like var = [x for i in range(whatever)] and I think that's more what I need to know
[QUOTE=Shadaez;39322803]to expand, there's also things like var = [x for i in range(whatever)] and I think that's more what I need to know[/QUOTE] [url=http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions]List comprehensions.[/url]
[QUOTE=codl;39325887][URL="http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions"]List comprehensions.[/URL][/QUOTE] thank you! edit: already using it a lot and it feels very powerful to do so much in a single line that used to take so many
[QUOTE=bull04;39305589]Hey guys, I'm still an extreme beginner at coding, but I am using C# with XNA to create a small game right now and I am running into a problem that won't go away. I have 3 classes, one which is Game1 (main), Ninjas (player class), and AI (AI class). I'm trying to code the AI currently and have derived the player's main entity into the AI class to read the X position so that the AI will walk towards the player when needed to. The problem is is that when I derive the redNinja class into my AI class and read the X position, I'm getting an "object was never assigned to, and will always have it's default value null" error. Here's my code for the AI class: [code[ Thanks.[/QUOTE] Hi, sorry for the late reply. When I place the code you gave us in an empty class, adding this piece of code to fix the errors of non-existing classes: [code] class Vector2 { public int X; } class Texture2D { } class Ninjas { public Point Position; } class GameTime { public TimeSpan ElapsedGameTime; } [/code] It indeed says redNinja is never used. (Maybe you should have said it was about redNinjas, would have saved me some time) In your constructor you don't set the redNinjas, and you never assign a value to it anywhere else. You just use the values of it, which is impossible since it is indeed, always null. Maybe you should have this as the constructor: [code] public AI(Texture2D texture, int currentFrame, int spriteWidth, int spriteHeight, Ninjas redNinja) { this.blueNinja = texture; this.currentFrame = currentFrame; this.spriteWidth = spriteWidth; this.spriteHeight = spriteHeight; this.redNinja = redNinja; }[/code]
I'm thinking about the best way to structure a 2D game project. I've read a bit about the factory design pattern, however I feel that that might not be the best pattern for this project. How would you, for example, structure a tilemap loader and renderer?
So this year as a major project we are expected to make a game in Visual Basic so that is the language being taught to us thought the year, now having made a 'game' in VB before I can safety say its not a game at all and to be honest I'd rather drop school then make another game in said programming language. SO I asked my computer tech teacher if I could use a different language and she said yes but obviously she won't be teaching me that language so I'll need to learn myself. Over the holidays I've been reading books on C++ and learning quite a few things(still basics really). My question is should I just continue with the C++ and make an actual game and get a higher mark (even if its on par with the quality of the VB game i'd get a higher mark due to it being self taught and a different more 'advanced' language etc etc) or go along with the class and like everyone else get a high C or low B. tl;dr Sorry about the mass spiel but I was just wondering is it worth it going all out and making a half decent (in a school based situation) game in a more difficult language (C++) or making an average visual basic point a click pos 'game' but having the careful guidance along the way. It just doesn't feel right making a game in an application developing programming language, am I right (probably wrong) what your experiences with 'game' making in high school computer ed classes. Cheers,
[QUOTE=Two-Bit;39327470]So this year as a major project we are expected to make a game in Visual Basic so that is the language being taught to us thought the year, now having made a 'game' in VB before I can safety say its not a game at all and to be honest I'd rather drop school then make another game in said programming language. SO I asked my computer tech teacher if I could use a different language and she said yes but obviously she won't be teaching me that language so I'll need to learn myself. Over the holidays I've been reading books on C++ and learning quite a few things(still basics really). My question is should I just continue with the C++ and make an actual game and get a higher mark (even if its on par with the quality of the VB game i'd get a higher mark due to it being self taught and a different more 'advanced' language etc etc) or go along with the class and like everyone else get a high C or low B. tl;dr Sorry about the mass spiel but I was just wondering is it worth it going all out and making a half decent (in a school based situation) game in a more difficult language (C++) or making an average visual basic point a click pos 'game' but having the careful guidance along the way. It just doesn't feel right making a game in an application developing programming language, am I right (probably wrong) what your experiences with 'game' making in high school computer ed classes. Cheers,[/QUOTE] You're probably going to be marked on readability and function rather than a programing language. Personally I'd do what best suits your situation when it comes, IE if you can make a better game with better code at the time with c++ go for it; however if there are more tools and help for VB I'd go for VB. Another note is that your teacher wants you to add onto the base game. Just submitting the base game is going to get you a c+ or b-; however if you add more features it should grant you a higher score.
Do you guys have any recommendations on web articles or blogs about game architecture? I've been googling around, but all I can find is people pointing to books, and my budgets a little tight at the moment, so I was hoping to just find the resources online (usually it's not that hard) By game architecture I mean how you structure your classes etc to handle multiple levels and different areas. I'm finding this is getting to be a problem when you want to make a game more advanced than something you'd find in an arcade. Thanks in advance,
[QUOTE=Elv02;39328798]Do you guys have any recommendations on web articles or blogs about game architecture? I've been googling around, but all I can find is people pointing to books, and my budgets a little tight at the moment, so I was hoping to just find the resources online (usually it's not that hard) By game architecture I mean how you structure your classes etc to handle multiple levels and different areas. I'm finding this is getting to be a problem when you want to make a game more advanced than something you'd find in an arcade. Thanks in advance,[/QUOTE] I basically just asked the same thing, you just worded it much better. :v: And I'd absolutely love to get an answer from somebody.
[QUOTE=Elv02;39328798]Do you guys have any recommendations on web articles or blogs about game architecture? I've been googling around, but all I can find is people pointing to books, and my budgets a little tight at the moment, so I was hoping to just find the resources online (usually it's not that hard) By game architecture I mean how you structure your classes etc to handle multiple levels and different areas. I'm finding this is getting to be a problem when you want to make a game more advanced than something you'd find in an arcade. Thanks in advance,[/QUOTE] just look at a few game engines or open source games to see how its done, why get a book on it
[QUOTE=Elv02;39328798]Do you guys have any recommendations on web articles or blogs about game architecture?[/QUOTE]What kind of game are you going for (like, 2D or 3D, does it have multiplayer)? The architecture you want really heavily depends on the type of game that you are making.
[QUOTE=CmdrMatthew;39332992]What kind of game are you going for (like, 2D or 3D, does it have multiplayer)? The architecture you want really heavily depends on the type of game that you are making.[/QUOTE] I'm going for 2D
What level of math should I be knowledgeable about if I want to do 3D (and other general) programming in the future? I don't want to be limited by my lack of math knowledge. I also want to be able to look at algorithms or equations on wikipedia and be able to understand what they're saying. I plan on learning online via udacity, coursera or similar and I'll be able to bother my girlfriend about helping me up do what she has done (calculus 2 or something). edit: Obviously there's always going to be something new to learn and I always want to be learning, but to get started with 3D stuff where should I be? [editline]23rd January 2013[/editline] lets add: what level of physics should I understand? Any other classes/subjects important to know to be a good programmer in general?
[QUOTE=Shadaez;39334622]What level of math should I be knowledgeable about if I want to do 3D (and other general) programming in the future? I don't want to be limited by my lack of math knowledge. I also want to be able to look at algorithms or equations on wikipedia and be able to understand what they're saying. I plan on learning online via udacity, coursera or similar and I'll be able to bother my girlfriend about helping me up do what she has done (calculus 2 or something). edit: Obviously there's always going to be something new to learn and I always want to be learning, but to get started with 3D stuff where should I be? [editline]23rd January 2013[/editline] lets add: what level of physics should I understand? Any other classes/subjects important to know to be a good programmer in general?[/QUOTE] Your going to need to know alot about matrices and vectors and stuff like that. ( Geometry, Trig, and Calculus pretty much )
[QUOTE=Duskling;39335106]Your going to need to know alot about matrices and vectors and stuff like that. ( Geometry, Trig, and Calculus pretty much )[/QUOTE] Calculus might be a bit more than you need, but generally speaking it's a lot more helpful to know WHY something works, rather than only knowing how to use it.
[code] public static String ReadInput() { Scanner input = new Scanner( System.in ); String line = input.next(); input.close(); return line; }[/code] why does this work once then give a java.util.NoSuchElementException the second time it's called?
[QUOTE=twoski;39336357][code] public static String ReadInput() { Scanner input = new Scanner( System.in ); String line = input.next(); input.close(); return line; }[/code] why does this work once then give a java.util.NoSuchElementException the second time it's called?[/QUOTE] I don't code Java, but shouldn't you check if there [i]is[/i] a nextline, before you try to read it?
Well i'm opening and closing the scanner every time and i'm just reading user input from the console so i dunno why it's giving me problems. Why does it work once then fail? I just want to read user input directly, nothing fancy.
[QUOTE=ECrownofFire;39336293]Calculus might be a bit more than you need, but generally speaking it's a lot more helpful to know WHY something works, rather than only knowing how to use it.[/QUOTE] Yeah, I don't like using things I don't understand. I tried to make a perlin noise thing and while I could probably follow a guide on how to implement it I had no idea what was going on and wanted to understand what I was trying to do.
[QUOTE=twoski;39336483]Well i'm opening and closing the scanner every time and i'm just reading user input from the console so i dunno why it's giving me problems. Why does it work once then fail? I just want to read user input directly, nothing fancy.[/QUOTE] [url]http://stackoverflow.com/a/1072000[/url] This should help. (Basically just remove the input.close() line)
Huh? If i call my ReadInput method a pile of times i'll have a bunch of un-closed Scanners though, won't i? Is there a way to close the scanner without messing with System.in?
How should I structure a mesh class if I want it the most VBO friendly possible ?
[QUOTE=evil-tedoz;39338063]How should I structure a mesh class if I want it the most VBO friendly possible ?[/QUOTE] In what language?
[QUOTE=twoski;39338005]Huh? If i call my ReadInput method a pile of times i'll have a bunch of un-closed Scanners though, won't i? Is there a way to close the scanner without messing with System.in?[/QUOTE] Read the second response from [URL="http://stackoverflow.com/questions/5919143/is-it-safe-not-to-close-a-java-scanner-provided-i-close-the-underlying-readable"]this[/URL] stack overflow page. It states that if you close the scanner, it will close your underlying stream. I would imagine because you're creating the Scanner in a method, once the scope is finished, Java will dispose of it. Don't quote me on that.
Quick question here: I'm using SFML2.0 and trying to call the "clear" function from sf::RenderWindow to clear the screen at the end of my game loop, however when I type in "clear" it gets highlighted, thinking it's supposed to be clear as in ios::clear - or so I'm assuming. The same thing happens with sf::Sprite move (turns into std::move) and many other commands. How do I get around this? I'm running Code::Blocks with GCC if that helps. [b]Edit:[/b] Here's a picture showing what's going on: [t]http://i.cubeupload.com/xltfhR.png[/t]
[QUOTE=Kabscure;39341188]Quick question here: I'm using SFML2.0 and trying to call the "clear" function from sf::RenderWindow to clear the screen at the end of my game loop, however when I type in "clear" it gets highlighted, thinking it's supposed to be clear as in ios::clear - or so I'm assuming. The same thing happens with sf::Sprite move (turns into std::move) and many other commands. How do I get around this? I'm running Code::Blocks with GCC if that helps. [b]Edit:[/b] Here's a picture showing what's going on: [t]http://i.cubeupload.com/xltfhR.png[/t][/QUOTE] Wait, is this actually causing a problem? Is it calling ios::clear instead of the SFML one?
Sorry, you need to Log In to post a reply to this thread.