• Post your way into programming.
    37 replies, posted
[QUOTE=BK201;43873252]I got burned by Signletons once, so I turn into a noisy bitch whenever I see a static variable. :v:[/QUOTE] It's funny, now generally regarded as an anti-pattern, it seems like almost every single reasonably popular cross platform game engine rely heavily on Singletons. Ogre, Cocos, Corona, Moai, etc... seems each time I read documentation for a game engine, there are a number of singletons. That said, most of the problems with Singletons are actually problems in C++ only. In C# or Java for example, singletons aren't really as problematic for example.
[QUOTE=Serapth;43874313]That said, most of the problems with Singletons are actually problems in C++ only. In C# or Java for example, singletons aren't really as problematic for example.[/QUOTE] Welp, I'm using a singleton in my game too. Even my teacher uses it in his framework. Care to explain why they can cause problems? I know it kinda breaks encapsulation by giving you a global pointer to access, But it's really a pain and time consuming to keep passing around a pointer to something you need in a lot of different locations.
[QUOTE=Hentie;43856682][url]http://www.byond.com/[/url][/QUOTE] Dont touch this for the love of god unless you like SS13, or if you're a massive masochist Alternatively challenge yourself to do something in it that runs faster than if executed on an 8086, its quite tricky
[QUOTE=Sergesosio;43881017]Welp, I'm using a singleton in my game too. Even my teacher uses it in his framework. Care to explain why they can cause problems? I know it kinda breaks encapsulation by giving you a global pointer to access, But it's really a pain and time consuming to keep passing around a pointer to something you need in a lot of different locations.[/QUOTE] The biggest problems with the Singleton are when you start getting into multithreading. You either have to implement a critical section/mutex, and slow your code down painfully, or you open yourself up to all kinds of race conditions, as different threads access the singleton. Also, frankly, its a global. This isnt necessarily bad, but it can be. Making changes to your singleton are invasive to all of your code, just like any global.
[b]Lua[/b] [url]http://wiki.roblox.com/index.php?title=Absolute_beginner%27s_guide_to_scripting[/url] :v:
[b]Objective-C[/b] [url]https://medium.com/on-coding/67cc41319bd8[/url] [url]http://www.raywenderlich.com/tutorials[/url] [url]http://online.stanford.edu/course/developing-ios7-apps-fall-2013[/url] [url]http://nshipster.com/[/url] [url]http://www.objc.io/[/url] [url]http://subjc.com/[/url] [url]http://iosdevweekly.com/[/url] [url]https://mikeash.com/pyblog/[/url]
Im just starting to learn programming in my High School Computer Science class. we're using Turing to learn the basics. I myself am using the OpenTuring fork and its ok. my teacher hates me though. He keeps thinking that because im not using the "School assigned" Turing, its all going to go wrong. Where it says ", count, " tries blah blah blah, I was trying to state a variable in between two strings. What I need to do that is have commas before and after the variable count. instead of seeing the mistake in the code, all he sees is a fancy editor that wasn't school approved and forced me to use the old shitty version of turing that the school has. At least now you guys can see the things we learn in grade 10 computer science. Its just a simple guess the number game. I could replace the 72 with Rand.Int(0,100) but the guy freaked out saying "That's not what I told you to do. make it a static number" But enough with all that, Turing is really cool for learning the basics. The OpenTuring project even adds OpenGL and fixes a lot of problems with it. Its even got great documentation built in with a help menu. Ill leave the home page for OpenTuring here along with an example program at the bottom here [url]http://tristan.hume.ca/openturing/[/url] Also, anything with a % is a comment in turing. sorry if it looks weird in the Code wrapper [CODE] var number:int%The answer var guess:int%What the user will type in var count:int%amount of times the user guessed number := 72%This used to be :=Rand.Int(0,100) but my teacher didn't like it count := 0%This will go up after every time the user guesses put "Guess the number between 0 and 100" loop%Loop that makes the quiz get guess%Asks the user for an answer if guess > number then put "Too High"%If the user guesses too high, it will state "Too High" count := count + 1%Adds to the guess count elsif guess < number then put "Too Low"%If the user guesses too low, then it will state "Too Low" count := count + 1%Adds to the guess count elsif guess = number%When the guess is equal to the answer then put "Correct!" count := count + 1%Adds to the guess count end if exit when guess = number%Exits the loop when the correct answer is guessed end loop put "It took you ", count, " tries to find the number"%Shows the total amount of tries to guess the number[/CODE]
Sorry, you need to Log In to post a reply to this thread.