Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411507 Posts in 69374 Topics- by 58429 Members - Latest Member: Alternalo

April 26, 2024, 12:31:02 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Writing your own code...
Pages: [1] 2 3 4
Print
Author Topic: Writing your own code...  (Read 3724 times)
armedpatriots
Level 0
**


Game Designer/ Programmer


View Profile
« on: October 20, 2014, 03:30:39 PM »

Hey guys. I have a question: How and when did you start writing your own code? I have been doing Unity tutorials on YouTube and other sites for a while now. However, I cannot seem to break away from just copying how they wrote their code in the video. For instance, I have been writing platforming code the same way for a year. That is the way I learned and I never deviated from the method. When I tried, I always just resorted back to the original way. Do any of you more experienced dev's have any tips for me? Also, is copying someone in the beginning a valid option, or is it a waste of time? I am interested in your responses.
Logged

I have not failed. I've just found 10,000 ways that won't work.
-Thomas Edison
Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #1 on: October 20, 2014, 03:53:19 PM »

Straight up copying is a bad idea, even early on. You never learn to solve software development issues yourself that way. There's going to be a point where you need to do something and there's nothing ready to be copied in.

As a tip for going beyond it, play with the code you get in tutorials. Try to see what you can alter and what interesting effects you get. See if you can improve the code, making it easier to read or more modular.
Logged
armedpatriots
Level 0
**


Game Designer/ Programmer


View Profile
« Reply #2 on: October 20, 2014, 04:24:48 PM »

Good tips. Thanks. Have anymore lol? Grin
Logged

I have not failed. I've just found 10,000 ways that won't work.
-Thomas Edison
Layl
Level 3
***

professional jerkface


View Profile WWW
« Reply #3 on: October 20, 2014, 05:06:54 PM »

Well, learn by doing. Look at some programming challenges aimed at beginners. Project Euler has good challenges. Really just try to write some solutions to problems yourself rather than copying it over from some stackoverflow answer.
Logged
EvilDingo
Level 1
*


View Profile WWW
« Reply #4 on: October 20, 2014, 06:08:01 PM »

I started by modifying existing code. I think it's important to understand what the code you're copying does, but you don't always have to. It's best to change small things here and there. You'll get more confident. You will absolutely hit a wall eventually where you'll need to create what you want. If you can do it, your games will be a lot more engaging than those who can't.

Logged

armedpatriots
Level 0
**


Game Designer/ Programmer


View Profile
« Reply #5 on: October 20, 2014, 06:11:12 PM »

Well, learn by doing. Look at some programming challenges aimed at beginners. Project Euler has good challenges. Really just try to write some solutions to problems yourself rather than copying it over from some stackoverflow answer.
Hey, thanks for that site. I am going to run through some of these excerises for sure!
Logged

I have not failed. I've just found 10,000 ways that won't work.
-Thomas Edison
jolene
Guest
« Reply #6 on: October 20, 2014, 06:48:57 PM »

i started "writing my own code" when i learned what an if statement was
Logged
crbonilha
Level 0
**


View Profile WWW
« Reply #7 on: October 20, 2014, 07:02:23 PM »

Project Euler is a website with challenges most aimed at math. It's a good start, but maybe too focused on one single topic.

There are lots of websites with problems for you to solve, and a few that I recommend are URI Online Judge and SPOJ.
These have problems at several programming topics, such as Graphs, Data Structures, Paradigms, Geometry, and so on.

I have been practicing on such websites for some years, and now I can easily rely on my own problem solving insights and techniques. Hope this would be useful for you as well.
Logged
Photon
Level 4
****


View Profile
« Reply #8 on: October 20, 2014, 07:25:22 PM »

Just so you know, there isn't anything necessarily wrong with copying code, especially for more common but complex problems; you can still learn from doing it and you don't have to reinvent the wheel. The key is to make sure you try and understand what you are looking at. If you just slap it down without a second thought, you may have new functionality but perhaps not the slightest inkling as to how it works. Like EvilDingo said, try messing with it and try to figure out what each little piece is contributing to the overall puzzle. That way, when you need to start tweaking it to your liking, you can better assess how to go about changing/rewriting it.
Logged
Ammypendent
Level 0
***


Indiedev


View Profile WWW
« Reply #9 on: October 20, 2014, 10:18:14 PM »

Actually the best way to start writing your own code is to start problem solving. In your game there will be stuff you want to put in; to do so you'll need to think of ways of how it can work.

For example, I want a feature on an options menu which a click of a button would change a sensitivity panel into a keyboard/joypad config panel.
 - I first think of what needs to be done (ie: panels need to either slide off screen or just be toggle visibility).
 - Then I think of the conditions for the behavior to happen (clicking button & making sure a button isn't currently being configured).
 - Those conditions turn into if statements (or some form) eventually and inside them I write the instructions of what should happen if that's satisfied.

And before you know it, bam! You're writing your own code to solve your own problems!
Logged

Twitter
Dacke
Level 10
*****



View Profile
« Reply #10 on: October 20, 2014, 10:37:32 PM »

Well, learn by doing. Look at some programming challenges aimed at beginners. Project Euler has good challenges. Really just try to write some solutions to problems yourself rather than copying it over from some stackoverflow answer.
Hey, thanks for that site. I am going to run through some of these excerises for sure!

If you're interested, we have a Project Euler thread with high scores, discussions and help. If you create an account, just post your friend code or ID and I'll add you to the high score.
http://forums.tigsource.com/index.php?topic=25406.0

I'm not sure if Euler is the best place to start, though. The focus is on solving math problems with programming. Which is a great thing to practice, but not necessarily the same thing as general programming.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
armedpatriots
Level 0
**


Game Designer/ Programmer


View Profile
« Reply #11 on: October 21, 2014, 01:56:08 AM »

Great information guys! I am going to dig deep tonight and start really making a conscious effort to do my own problem solving. What do you do when you have tried everything and you get stuck? Do you come to the boards? I am just curious about your process.
Logged

I have not failed. I've just found 10,000 ways that won't work.
-Thomas Edison
R.D.
Level 2
**


Making a game about balls. Yepp.


View Profile WWW
« Reply #12 on: October 21, 2014, 02:33:15 AM »

Personally I always try to solve it on my own. If I have trouble with some aspects (like math), I check out wikipedia-like pages about the basics. It always good if you not just google for the answer to a specific problem but check out the source of it. So you have a better understanding WHY it has to work.

However if you're being confident with your skills, making use of existing solutions is smart too. You save time coding it yourself. Engine, libs and so are made for using them. You just have to make sure you know that they to in case you want to change something. So yeah, basic are important.
Logged

Dacke
Level 10
*****



View Profile
« Reply #13 on: October 21, 2014, 11:05:56 AM »

Don't be afraid to ask stuff. Most people learn skills from others -- be it through courses, tutorials, tutoring or irc/forums. It's all too easy to fall victim to the idea of the solitary genius, but that's not how stuff works (usually). Once you have a solid foundation you will be able to solve most problems by looking it up on StackOverflow, Wikipedia or tutorials. But you won't find the right answer if you don't know how to ask the right questions, so when you're fresh it's usually better to just ask about everything.

I do think it's a good idea that you try to learn how to program on your own, from scratch. But beware of not-invented-here-syndrome, where you feel the need to make everything on your own. Feel free to program your own stuff in order to learn how to do it. But when you are making an actual game it's usually better to copy as much as you can from people who are more experienced (via libraries, examples, tutorials, etc.). That way you'll get more done, get better code and most importantly learn to use a good coding style and good design patterns.
Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
ubik
Level 0
***


View Profile
« Reply #14 on: October 21, 2014, 10:17:13 PM »

Start by learning a language well.  Learn memory management, algorithms and data structures.  I recommend C.  Others may recommend more high level languages but typically these people do not understand what's going on under the hood.

I also recommend the free book Structure and Interpretation of Computer Programs.  I also recommend K&R C in addition to some modern edition of the C Programming Primer.  Study that until you know it backwards and forwards.  Consider learning all the shorter programs in K&R by rote.  Sound excessive?  Rote memorization is awesome and there may be something special about it when considering programming... you may actually be encoding an understanding of what you are memorizing.  It may be that you will suddenly understand certain concepts far better than makes sense from raw memorization of text.

Also it's possible you don't actually want to be a programmer.  Think hard about that.  Do you find algorithms and data structures fascinating?  If not, consider doing something else other than programming, there are lots of jobs that need to be done in game development and maybe something else is more suitable to you.  If you do not have and cannot acquire an enjoyment of programming in and of itself and separate from the PEW PEW factor of games, programming will always be drudgery for you and honestly you may be better off doing something else.

The fact is, game programming is one of the hardest kinds of programming there is and beyond something trivial like asteroids games the level of difficulty is sort of exponential.  That is because of complexity management.  Boilerplate solutions will not work unless your game is not doing anything new and games that do nothing new are not interesting.  Writing a platformer game is one thing and is actually not the easiest kind of game to write for a number of reasons.

  You can get by for a while without knowledge of what's under the hood.  Modern packages like Gamemaker and unity try hard to abstract it for you and obscure the difficult parts.  But once you start getting into games with lots of collisions, AI, networking code, shaders, 3D, complex inventories like RPG games, you will very rapidly hit a wall where you are simply not able to manage the complexity involved.  It will be like wading through deeper and deeper mud, then there will start to be more and more barbed wire in the mud.  Even fairly simple SHMUPs have a surprising amount of difficult stuff in them involved with the structure, scrolling, handling large assets, asynchronous loading from disk...

You need a firm basis in programming and some concepts in software engineering.  Continue doing what you are doing but begin a lifelong study of computer science.  Start now and in a few weeks things will start to become a little easier and you will at the very least begin to understand what your weaknesses are and how to address them.

I also recommend that you begin to use linux and gain an understanding of how that works.  You can run it in a virtual machine, that will be fine.  The reason is because there are thousands of computer language resources available on linux, such as C, LISP and easily accessible assembly language that are much easier to get set up than on windows machines.  Develop an enjoyment and desire for learning languages and new things.  They will all teach you something new.  I'm still learning new things 35 years after I wrote my first BASIC games.

Good luck!
« Last Edit: October 22, 2014, 01:29:52 AM by ubik » Logged
Dacke
Level 10
*****



View Profile
« Reply #15 on: October 22, 2014, 01:36:29 AM »

I don't agree with ubik at all.

I think I am one of those "real programmers" that ubik is talking about. I've studied computer science, math, I exclusively use Linux (it does make things easier), I've built stuff using only logic gates and I think data structures and algorithms are more fun than games. Having that baggage helps, sure. But it's not like I actually need it 99.9% of the time. You don't need to understand how a processor works or how to do manual memory management in order to make a game. As long as you know your limits you can make great games. For example you may only need to know some basic scripting in order to create a fantastic game using modding or a genre game engine (visual novel, text adventure, etc.).

Don't get me wrong; if you feel like it, starting from the ground up is a 100% legitimate approach. The risk I see is that you can get stuck and loose motivation before you get anywhere -- and for no good reason. I didn't start with the most basic stuff and it hasn't limited me from learning it later. To begin with, I think the low level can get in the way of the more important higher level concepts, like understanding control structures (if/while/for), functions and basic data structures (variables/arrays/lists/dictionaries/maps).

I most strongly disagree with the sentiment that you have to "think hard" about wanting to be a programmer. You really, really don't have to treat it like a lifetime commitment. Just learn some programming, it will be useful even if you only learn a bit. You just need a bit to create lots of fun things. It also helps you think structurally about problems and games in general. If you later decide to collaborate with professional programmers instead of writing your own code, they will no doubt appreciate it if you have some basic understanding of what they do.
« Last Edit: October 22, 2014, 01:50:11 AM by Dacke » Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
ubik
Level 0
***


View Profile
« Reply #16 on: October 22, 2014, 02:01:13 AM »

Quote
But it's not like I actually need it 99.9% of the time.
You're underestimating your own level of knowledge as well as the necessity of knowing what you're doing.  You may not understand just how hard it is for these guys who want to program games so badly but they constantly run into problems and the reason why is because they don't have the fundamental skills they need.

Not only are you engaging in game programming, which is hard enough if you know how to program, but you're constantly reinventing the wheel.  You're essentially having to reinvent computer science as you need it piece by piece and while that's certainly possible it's much easier if you've learned the field as opposed to coming up with your own version of the field while you write what you want to write.

Quote
I most strongly disagree with the sentiment that you have to "think hard" about wanting to be a programmer.
A lot of people are not cut out for it and that's just a fact and you know that.  I think a lot of guys are fed a bill of goods about what it is and how much work and study goes into it and to some extent you're doing that here.  

Quote
You just need a bit to create lots of fun things.  
Lots of small fun things.  Writing something bigger is different.  There are several obstacles, the most insurmountable of which is nontrivial complexity.  Even basic game structure surprisingly nontrivial.  Then you have menus, a GUI if you're going to do that, game state management, asset loading, music handling, etc etc etc.

The fact is it's computer science.  You can actually learn it, and do that while you're doing what you want to do, or you can make lots of small fun things in Gamemaker and leave it at that.
Logged
Dacke
Level 10
*****



View Profile
« Reply #17 on: October 22, 2014, 02:15:45 AM »

I base my statements on the fact that I made games before I studied computer science. Sure, it's more work if you're inexperienced. But making games is a legitimate way to gain that experience.

Personally, I think that anyone who didn't flunk math in school or is motivated enough should be able to learn some programming and get some real use out of it.

Writing something bigger doesn't have to be different. You just have to understand your own limits use the right tools. There are many ways to get resource management, menus, GUIs, music, settings, etc. ready made for you (modding, genre engines, game libraries, game engines). Sure it's nice to build it on your own in order to get more control, but it's far from a requisite these days.

also:
small, simplistic or limited in scope ≠ bad
There are small, simplistic games that have become extremely successful, for example CookieClicker.
« Last Edit: October 22, 2014, 02:52:09 AM by Dacke » Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
ubik
Level 0
***


View Profile
« Reply #18 on: October 22, 2014, 03:02:53 AM »

Or Flappy Bird.  Flappy Bird made millions of dollars.

With a lot of things like this though it's a lot easier to bite the bullet and frontload the difficulty.  The people who don't do it are typically separated pretty distinctly from those who study and do the hard work.

small, simplistic or limited in scope = small, simplistic or limited in scope.
« Last Edit: October 22, 2014, 03:17:24 AM by ubik » Logged
Dacke
Level 10
*****



View Profile
« Reply #19 on: October 22, 2014, 04:02:38 AM »

...or mods (DotA), interactive fiction (Depression Quest), games with simple mechanics but strong content (Loved), visual novels (Magical Diary), RPGMaker games (To the Moon), games made with scriptable genre engines (fighting games, shmups, etc.) etc.

I think your view of games programming is too narrow. Again: small, simplistic or limited in scope doesn't have to be a bad thing, like, at all. If all that mattered was complexity and size we'd all dump this indie crap and try to go AAA. But a game can have so many more strengths than mechanical/technical ones. The great thing with the current generation of easy-to-use game tools is that they allow people with another primary interest (like art, writing, audio, etc.) to create their own games.

I think the problem is that you're thinking like a programmer who is looking for inventive programming in games.

Boilerplate solutions will not work unless your game is not doing anything new and games that do nothing new are not interesting.

But you can create something completely new and interesting simply by adding unique content (art, text, story, level design, sound, etc.)

I kind of agree that it's a good idea to frontload some stuff (some data structures and computational complexity). But to include manual memory management (which I, personally, never use) or the need to learn a low level language like C just sounds silly to me. I don't get why you'd need to understand what's going on under the hood. I could code just fine before I knew the details of assembly/compilers/processors. In the same way, someone can write Python or JavaScript just fine without understanding what the interpreter or garbage collector is doing.
« Last Edit: October 22, 2014, 04:08:19 AM by Dacke » Logged

programming • free software
animal liberation • veganism
anarcho-communism • intersectionality • feminism
Pages: [1] 2 3 4
Print
Jump to:  

Theme orange-lt created by panic