Jump to content
  • Advertisement
Sign in to follow this  
EagleGamer

Is copy pasting code a good practice as a beginner game developer?

This topic is 1216 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Good morning/evening.

 

I've already finished my first game and working on my second simple game, I'm using tutorials with open sourced projects to write those games. All what I do is put the IDE on the right and put the source on the left and type in the IDE. I understand most of what I'm writing but I never really memorize those things if I'm ever asked to write them again. Is this how I'm supposed to learn? Or should I try to memorize the code from the source and try to write it down in the IDE? Or should I write it multiple times to memorize it eventually?

 

Its just that I see many game developers on youtube that code on the go and don't really look at sources when they're making their games throughout their videos. What are the best practices that I should do to learn game programming faster?

 

Sorry for the long read, thanks in advance smile.png

Share this post


Link to post
Share on other sites
Advertisement

The best thing to do is get an understanding about what the code is doing, what API's and building blocks the code is using and how they are connected.

 

As other have said, programming is problem solving. While all developers might search for info on new API's they have not encountered before a good developer will look at samples and try to understand what is being done so they can take that knowledge and apply it to their given situation.

 

Aim to expand your knowledge so you can construct from fundamentals if you can. When you have a deep understanding of the code you find it easier to find issues and bugs when things go wrong.

 

Code is meant to be fun. Learn and expand your mind and enjoy the process :) 

Share this post


Link to post
Share on other sites

It's fine when learning to copy code from tutorials, as long as after you see that the code indeed works, you play with it and modify it to learn how it works, by trying to get the code to do different things. I've found that very helpful when learning to program.

 

The biggest issue is not memorizing function names, but learning how coding works in general.

Share this post


Link to post
Share on other sites

My personal opinion. No not really. But there are exceptions to that rule.

A. When you copy the code, you read the breakdown of the code to see how it works.
B. You copy the code and modify it to see what would happen if you do something to it.
C. You copy the code in its Pseudo code format, but convert it into actual code.

Either way, you need to make sure you got the concepts. Not the code.

Share this post


Link to post
Share on other sites

I agree with the others. I copy and paste code, but I try to understand what it does if I didn't write it. If you are copying the magic spell that will magically make your code work, then no, don't just copy it. Understand what it does.

 

This also applies to code libraries. I spent years working on a set of functions to replicate the pixel-perfect drawing routines of the original Macintosh's QuickDraw (I started programming on a Mac 512KE in the late 80's). I hated that it was doing something that I didn't understand and was so closely guarded, so I spent nearly a decade trying to figure it out (before the internet, when such information was not freely shared and difficult to find). I wrote a perspective correct texture mapping software renderer just because I wanted to know how it was done, more or less, in hardware. It bugged me that I sent vertices and a texture to the GPU and it "magically" rendered the triangle.

 

The point is, don't rely on code samples to do the work for you unless you fully understand what they are doing and have the ability to modify them. You will do yourself more harm than good in the long run otherwise.

Share this post


Link to post
Share on other sites

Most of above advices are (obviously smile.png ) from experienced developer who like my just forgot how it is to learn programming for the first time. If it was a year ago I would respond the same. Recently my kid started to bother my to teach him this magical thing so I found a (great) book about making games in python. So far, so good, the book starts great with simple console based games (guess a number, hangman, tic tac toe, etc...). This is good pace at start where first samples are 20-30 lines, but it quickly gets to the point were retyping the code by hand is just... I don't know? Boring as hell?

 

So the option are:

1. We can copy the source code or just open provided file in IDE. That way it is more work to go through code to understand what it does and no way to catch some "clever" tricks.

2. We can re-type everything by hand falling asleep a few times on the way. Given how tedious is this task it is also no way to understand everything on the way and catch any "clever" tricks there are father than line 20 smile.png

 

So I would say don't feel guilty that you "cheat" copying the code. Just do your best working through it so you understand roughly what it does and can get back to it to check how something was implemented. Also for every sample you work on try to implement something similar yourself. That way you will have to go back to the sample and figure out things you skipped at first as "simple" or "obvious".

Edited by Deflinek

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!