[Tutorial] Learn to make a game in C++

[Tutorial] Learn to make a game in C++


[Tutorial] Learn to make a game in C++

Posted: 16 Aug 2016 06:07 AM PDT

Hello fellow game developers!

My main goal for this series is to share my game development knowledge with you. Watching this will not only teach you how to make a game from scratch in C++, but it will also more than likely teach you a thing or two about programming in general. You should be able to walk away from this tutorial with enough knowledge to create your own game in C++ and SDL2.

These tutorials are very beginner-friendly because in each video, you will see me write every single line of code from scratch. I also explain all of the classes, functions, and algorithms that I implement throughout the series.

Also, all of the updated source code can be found on Github by following the link at the bottom of this post!

Feel free to provide me with any feedback you may have.

Click here for the playlist containing all of the videos in the series!


And here are some other important links:

For information on my current project, Lime2D, click here!

Thanks for checking it out and I hope you enjoy. Make sure to contact me with any questions or suggestions!

submitted by /u/Limeoats
[link] [comments]

My FREE journey to becoming a software dev

Posted: 16 Aug 2016 09:03 AM PDT

TL;DR as suggested by /u/iamquah

  1. Coursera's An Introduction to Interactive Programming in Python and edX's Introduction to Computer Science and Programming Using Python
  2. Free HTML, CSS and Javascript tutorials on Codecademy and CodeSchool
  3. Codecademy's PHP and MySQL tutorials
  4. Use FreeCodeCamp as blueprint (while also using other sources)
  5. Coursera Twitter Bootstrap course and Twitter Bootstrap docs
  6. Coursera's Algorithms by Princeton and Algorithms by Stanford
  7. CodeSchool's free jQuery course
  8. Codeschool's free Angular course
  9. CodeSchool's free Chrome DevTools course
  10. CodeSchool's free Chrome DevTools course
  11. NodeSchool's tutorials 12.NewBoston's Node tutorials
  12. Official Angular 2 tutorial
  13. ???
  14. Write post on Reddit to help others

Recently, there was a post blasting Bloc.io. I realized there that some /r/learnprogramming readers are down and out about learning to program by their lonesomes and using the free material available online. I thought I'd share my journey to getting a programming job. Let's start, eh?

My intrigue for programming all started with Coursera's An Introduction to Interactive Programming in Python and edX's Introduction to Computer Science and Programming Using Python. I took these two courses concurrently. They laid out a foundation for my future in computer science. A good foundation is necessary as you will be confused without one once you start building.

From there, I completed the free HTML, CSS and Javascript tutorials on Codecademy and CodeSchool (I believe they've some courses for free such as jQuery). It was then that I realized programming across several languages is a bit different due to syntax but the same foundational principles are applied.

Cool, now I've some HTML, CSS and Javascript under my belt along with Python. I applied to a part-time job at a local college for some minor website fixes. They asked me some HTML and CSS stuff. They were using PHP as well which I never used. To Codecademy's PHP tutorial! Uh oh, they're using MySQL, too? Nice. Codecademy has a tutorial for that too. It kind of sucks but, hey, it's something. On the job I learned PHP and MySQL as I went. I was able to fake it all. :)

During that time, I networked with local businesses. I thought, hey, I know to write websites, why not write websites for local businesses? I found a client that let me write their website. I used a template found on w3 Layouts, customized it a bit and gave it to the client. He was pleased. Between you and I, Redditors, it was a shit website. But the more I wrote, the more I learned.

It was around this point that I discovered FreeCodeCamp. Wow. An entire curriculum (game plan) I can follow to achieve my goal of getting a REAL job. Love it.

Let me stop here for a second. FreeCodeCamp is a blueprint to follow. Some users have commented that FreeCodeCamp isn't too good at teaching HTML, CSS and Javascript. I would agree. However, the resources in this post WILL teach you. Follow the FreeCodeCamp blueprint and use other resources to help you complete the curriculum.

Back to my story. I flew through the FreeCodeCamp HTML, CSS and JS stuff. FCC introduced me to Twitter Bootstrap but, again, it didn't teach it TOO well. I used the Twitter Bootstrap docs to supplement anything I missed but I still didn't feel too strongly about Twitter Bootstrap. It wasn't until I took the Coursera Twitter Bootstrap course that I was confident in Bootstrap.

The algorithms (a part of the FCC curriculum lots of users have trouble with) weren't too bad since I took those Python courses. I also took two Coursera algorithm courses: Algorithms by Princeton and Algorithms by Stanford. Oh, I also had played around with CodeWars and Project Euler a bit. Writing algorithms was a fun puzzle to me.

I learned the jQuery stuff through CodeSchool's free jQuery course and flew through the jQuery FCC challenges. At the time, FCC recommended Angular. I took Codeschool's free Angular course and used that to write my front end development projects. At this point, I fell in love with Angular. Irrelevent plot point but I thought you should know.

By the way, if you haven't noticed, I'm supplementing FCC's curriculum with Coursera and CodeSchool courses. There are SO many free resources online. Why use just one?

OK, so back to FCC's curriculum. Up next was their backend certification (which I still haven't completed, FYI). Automated testing and debugging? Sweet. CodeSchool's free Chrome DevTools course can help. Git? Nice. CodeSchool's free Chrome DevTools course. By the way, after I learned Git, I jumped right into FCC's GitHub issues to see if I could contribute. Contributing to FCC on GitHub helped me learn Git more than any course did. Node, Express and MongoDB? NodeSchool has free tutorials on that. Honestly though, Node was a bit hard. I needed some more help. NewBoston's Node tutorials helped clarify some stuff.

After a year of working at my part-time job and acquiring all this knowledge, I thought it was time to apply to for a real job. I applied to EVERYTHING. I used GitHub, StackOverflow and Indeed job boards. I had some phone interviews but luckily caught onto one. My PHP experience (which I learned on the go and with Codecademy) came through. After two interviews, I landed a software engineering job using PHP and a MySQL database.

I'm STILL not done learning though. I'm working on Angular 2 and learned that using the official Angular 2 tutorial. I'm using Node, Express and MongoDB to keep with the MEAN stack and FCC. I haven't worked on any backend projects since I diverged and began trying my hand and some personal projects.

What I want everyone to get from this post is that learning for free CAN be done. Don't rely on one resource. View FCC as a blueprint and use other resources to learn from there.

You got this, guys.

Edit: Forgot them algorithms.
Edit2: Who wants to read all this text? Road map!

submitted by /u/BooG690
[link] [comments]

How fast is D?

Posted: 16 Aug 2016 05:18 AM PDT

Hey guys, I heard about the D language a long time ago and I understand it is still in development but checked recently and it seems that it is now pretty stable. However, I've tried to find benchmarks comparing D to C or C++ and haven't found many.

Anyone knows how they stack up to each other?

submitted by /u/Infernael
[link] [comments]

Can someone recommend a good guide for Lua? (my first language)

Posted: 16 Aug 2016 02:23 AM PDT

*PLEASE READ THIS*

I've never done any sort of programming whatsoever so I'm not familiar with any of the software's associated, nor am I familiar with any of the lingo people use, and to top it off I'm on windows 7.

I'd like to learn Lua but most of the guides/tutorials seem to assume people have some basic understanding of programming in general, and I don't. Please help :(

submitted by /u/TrinityTextures
[link] [comments]

How to help a child learn and love programming?

Posted: 16 Aug 2016 04:09 AM PDT

Hi guys,

I will be meeting my nephew in a few weeks and he has told me he is interested in learning about programming. I am a programmer, but I am still in college so I don't have too much experience with how I can teach others how to code or anything like that.

He is about 10 years old, and doesn't really know much about coding besides "You can make computers do cool things!" This isn't his final career choice, of course, but I think it's great that he wants to explore it.

I told his dad to put him in a computer science club to help him learn, but his school doesn't have a proper coding class till Sophomore year of high school. Since I am going to visit him, is there anything I can do to help him out? I know programming in most of the major languages like Java, C++, and Python and could teach him the basics, but I don't think those would be good for him yet. If I was his age and the first experience I got of programming was

public static void main(String[] args) { 

I would probably just quit. I suppose Python would be an easy first language because it's basically pseudo code, but is there something else that I can do? I guess some HTML could help first too, even if it's not really "programming" according to some people.

Thanks!

submitted by /u/Virat97
[link] [comments]

[Concurrency] Lecture videos of Professor Herlihy: The Art of Multiprocessor Programming

Posted: 16 Aug 2016 03:01 AM PDT

For anyone who is interested in the foundations of concurrent programming and some excellent examples of concurrent datastructures (examples in Java), I can highly recommend watching the lecture videos of Professor Herlihy:

Lecture Videos: http://www.brown.edu/cis/sta/dev/herlihy_csci1760_fa12/#vid

Course Slides: https://www.dropbox.com/sh/s1575nan4lp54ds/AADEElTV25aswPcliVAhI5vWa?dl=0

Plus I recommend the book "The Art of Multiprocessor Programming", which is written by him and Prof. Nir Shavit.

submitted by /u/rareriro
[link] [comments]

[HELP] Software Engineer in Test job interview.

Posted: 16 Aug 2016 06:01 AM PDT

Hi!, I have an upcoming job interview as an SET, and Im not sure if I know everything I should. Does anybody here have any tip or list of stuff that I should know before going ham into the interview? (PD: I am currently employed as an Automation QA).

Thanks!,

F.-

submitted by /u/Decimator7
[link] [comments]

[C#] is it more taxing for a computer to process a float like 0.10000000000234 than 0.1?

Posted: 16 Aug 2016 08:58 AM PDT

Seperating List by day created [Rails/Bootstrap]

Posted: 16 Aug 2016 05:34 AM PDT

Hi I'm creating a site with rails and bootstrap where I have a list group populated with posts. I want to be able to have seperate list groups for each seperate day.

For example at the moment I have:

<ul class="list-group"> <% @posts.each do |post| %> <li class="list-group-item">User has... <%= post.title%> </h2 class="pull-r"> <span class="pull-right"><%=link_to 'View', post%></span></li> <%end%> </ul> 

Which give me:

http://i.stack.imgur.com/MSmF2.png

However I want it to look like:

http://i.stack.imgur.com/Ro1Ir.png

(though obviously with different posts for each day)

but I'm having trouble, any help would be great.

submitted by /u/chris24680
[link] [comments]

Need some clarification with CodeBlocks (C Programming)

Posted: 16 Aug 2016 12:39 AM PDT

Hello Reddit,

I am not completely unfamiliar with C programming as I have written a bunch of programs for class but I needed a few things clarified.

I understand that C programs contain header and source files (.h and .c respectively) and have a basic understanding of what they do.

Now, enter CodeBlocks. I learned that "projects" are "programs".

My confusion is I have all these programs I wrote like arraysort.c and integersum.c, etc a bunch of random ones. Do I create a project for each of these programs and paste my code into the main.c for that project? I wanted a way so that I can have a bunch of different programs up on CodeBlocks, write/edit and compile/run the programs with ease but looks like I have to create projects for each and then load the projects when I want to run them.

Oh yeah, also, CodeBlocks made me choose a folder for my "projects", and created a Debug and an Obj folder. What are these .o files? Sorry for the noobie questions!

submitted by /u/regarizer
[link] [comments]

Are there any good online tutorials to learn about advanced data structures in Python, i.e. trees?

Posted: 16 Aug 2016 08:04 AM PDT

[Java] ELI5- What does "resource" mean and why should you close it?

Posted: 16 Aug 2016 04:04 AM PDT

I tried looking up videos for it/googling it, but I can't seem to get it. Can soemone here offer me a dumb down explanation of it?

submitted by /u/throwawaysock1
[link] [comments]

Let's learn Java together! Group project.

Posted: 16 Aug 2016 11:42 AM PDT

Hi there!

We are writing two projects with friends, as much as everyone has the time. Objectives are purely educational. Those who know the basics of Java, and want to learn Spring or Android can join by sending me private message with Spring Boot Hello World shared on github or any other source control (but we are using Git :P). Also you can message me for more information.

http://projects.spring.io/spring-boot/

submitted by /u/Henorek
[link] [comments]

What are tips you can recommend to accelerate learning of programming?

Posted: 16 Aug 2016 11:28 AM PDT

I think I'm an intermediate programmer, because I am aware of how much I don't know. I also worked on a paid job, so there's that.

I know there's no super-fast way to learning how to program (maybe there is, if you know it, share it), but what are some tips that can accelerate my learning of programming and programming related topics?

P.S. I have already read "Learn Programming in 10 Years".

submitted by /u/The_Grey_Wolf
[link] [comments]

Iterate through an array isn't working.

Posted: 16 Aug 2016 11:17 AM PDT

I'm very new to coding so please be kind!

I want to iterate through a string to change each vowel to the next vowel (with "u" changing to "a"). I cannot figure out how to make the iteration loop through a string OR index that I define, rather than a default .next, for example.

I can figure out how to iterate through arrays and hashes, change them, store them, but not to iterate through and change each thing to another thing that I specify:

Here is my very not working code:

name = "aaaeee" new_name = name.split("") p new_name

new_name.each do |modified| vowels = "aeioua" index = vowels if modified.include? index modified = new_name[index + 1] p modified_name end

end

submitted by /u/TurangaLovesFry
[link] [comments]

[C] Troubles with a BMP resizing program

Posted: 16 Aug 2016 11:12 AM PDT

Hello everyone, my assignment for the week was to make a program that reads data from a bmp image and then edit it according to a user-specified scale factor.

Everything was going great until my final function, the function that actually reads pixels from the input pic and writes them(most likely edited) in the output file. I get weird outputs, the original pic was supposed to be a green pic with a white box inside; however, I am getting blacks and some weird colors.

Here is the section of the code that has the issue

void draw_image(int scale) { //iterate over infile's scan lines "/ scale" is used to get teh original value of biHeight. for(int i = 0, biHeight = abs(bi.biHeight / scale); i < biHeight; i++) { //writes the line * scale factor for (int m = 0; m < scale; m++) { // iterate over pixels in scanline for(int j = 0; j < (bi.biWidth / scale); j++) { //temporary storage RGBTRIPLE triple; //read RGB triple from infile fread(&triple, sizeof(RGBTRIPLE), 1, ioptr.inptr); // write RGB triple to outfile * the scale factor fwrite(&triple, sizeof(RGBTRIPLE), scale, ioptr.outptr); } // skip over padding if any fseek(ioptr.inptr, padding.oldPadding, SEEK_CUR); // write the new padding for(int k = 0; k < padding.newPadding; k++) { fputc(0x00, ioptr.outptr); } } } } 

Here is a link to all of my code(it also contains all the .h files) http://pastebin.com/CgQ04ezw

Thanks in advanced :)

submitted by /u/llFLAWLESSll
[link] [comments]

Was excited to learn programming, but life has given me a big hurdle.

Posted: 16 Aug 2016 11:01 AM PDT

I have been excited to go to my local university for a Bachelors in Computer Science. I had been in talks with the Uni and everything, but my student finance has turned around and said they won't fund me. So now I feel stuck, completely uncertain what my next option could be.

So I'm asking people who may have been in a similar situation and really wanted guided teaching: What is my next best option? Or is there really nowhere else to go but attempt to self-teach? I'm sure I could, but finding the time whilst working to afford rent seems difficult. Any help would be appreciated, but would love something comprehensive.

submitted by /u/WilhouseInferno
[link] [comments]

[java] How to highlight a line in a TextArea with one click?

Posted: 16 Aug 2016 10:52 AM PDT

say I have a text area that contains this text;

Hello! How are you? I am doing just fine thanks. 

I would like to set it up to where if I click one time anywhere in the row that contains "How are you?" it will highlight all of the text in the row.

To be honest, I've already figured out a solution. but it feels rather.... clunky. I feel like this functionality is seen pretty much everywhere so there must be an easier way. I've scoured the web and really couldn't find a solution for this problem. could you help me out?

My solution is;

//'ta' is a variable that refers to a TextArea object int location = ta.getCaretPosition(); int lastNewLine = 0; int nextNewLine = 0; String text = ta.getText(); for(int i = 0; i < location; i++){ if(text.charAt(i) == '\n'){ lastNewLine = i; } } for(int i = location; i < text.length();i++){ if(text.charAt(i) == '\n'){ nextNewLine = i; break; } } if(nextNewLine == 0){ nextNewLine = text.length()-1; } ta.selectPositionCaret(lastNewLine); ta.deselect(); for(int i = 0; i < nextNewLine-lastNewLine; i++){ ta.selectForward(); } 
submitted by /u/169347
[link] [comments]

Need help choosing a database that allows me to store and search JSON objects

Posted: 16 Aug 2016 10:52 AM PDT

Hey Reddit, I need help picking a database.

The main requirement is that I can store JSON objects a column AND most importantly I can easily query for key/value pairs to see if they exist anywhere in a JSON object tree.

I wrote up a post on stackoverflow yesterday, so instead of re-writing that post I will just link to it: http://stackoverflow.com/questions/38962904/database-with-ability-to-search-json-object

Thank you.

submitted by /u/wanderingsoul_
[link] [comments]

I could use some help I am new to coding (c++)

Posted: 16 Aug 2016 10:50 AM PDT

.#include <iostream>

using namespace std;

bool isOn = false;

void ButtonPress()

int main()

{

isOn = !isOn;

if( isOn ) {cout<<"you have activated the aim bot";}

else {cout<< "The aim bot is inactive";}

return 0;

} for some reason i get this error (expected initializer before 'ini')

submitted by /u/Galiron49
[link] [comments]

[Python] Created my first game in Pygame. Am I doing this right?

Posted: 16 Aug 2016 10:45 AM PDT

A little bit about me, I've been programming for about a year and a half now and this is my first foray into making games. My main experience programming is a college class in C++ which I did pretty well in and handled most of the assignments in. Making a game is one of the hardest things you can do in programming (at least in my experience), so I thought I'd try it to see if I could do anything besides writing little code snippets that accomplish simple tasks. I tried to do it in C++ but it was such a pain to set up the library and the engine with the compiler and getting everything to work together. I literally spent weeks trying to get it all to work and it just wouldn't budge, even with the internet's help. Python was much simpler and I could actually get the damn engine to work with it. All I had to do was drag a file and write "import this" to get my engine set up. Also, I had dabbled in Python before and I knew most of the concepts from C++ (variables, loops, functions, classes, etc.) that applied to most other major languages, so it really was just a matter of recognizing the slight (or "slight") irregularities and nuances between Python and C++. I'm by no means an expert on Python (I'm not even an expert on C++), but I feel like I have an adequately good grasp on how it works and the differences between it and C++. YouTube and other online platforms have helped me learn too. All that being said, I recognize that I could also be completely delusional and writing things that work but are written terribly. So here is my game so that you can see for yourself what I'm doing wrong/right.

As for the game, what I have right now is painfully simple. It's just the foundation for the game, I want to get feedback before I expand on it and inevitably screw up badly. Basically the concept is that you have to avoid getting hit by the blocks that are moving right to left by moving over and under them. The controls are similar to the game Jetpack Joyride where you hold down a button to go up and release it to go down. Right now there's no way to "lose", but I'm gonna add that later along with scores and progressive difficulty. But what I'm worried about right now is the code. Is it written in a way that's overly-complicated and will lead to problems in the future, or have I put myself on a good path?

submitted by /u/TheEternalThrowaway
[link] [comments]

Differences between accounting and programming

Posted: 16 Aug 2016 10:41 AM PDT

I currently work in accounting but I find programming much more enjoyable and relatively less painful to learn (considering a career change) - though, some people I've known think they require a similar skill set.

My thought is that accountants do better at administering an existing system put in place (speed and accuracy), as opposed to a programmer who investigates and creates the systems for others to use. Basically, engineering vs business administration.

Anyone feel like that there are some major differences between accounting vs programming, and ones ability to do well in one vs the other?

submitted by /u/asimonia
[link] [comments]

[C] Need help deciphering output from reading the bytes of a .bmp file

Posted: 16 Aug 2016 10:26 AM PDT

I'm working on this project to implement JPEG compression in C, but I'm having trouble with the very basic first steps of this involving reading the pixel array data from the .BMP image file.

Here is a URL to the source code of the only file so far that's used in the program. I am essentially attempting to re-create this example of the format of the .BMP image file from Wikipedia and at least read in the two headers and the pixel array data correctly... however, that's where I'm getting stuck.

If you take a look at the output example I have in the provided repository, you'll see that at the end I have the pixel array data shown:

::begin of BMP header (14):: 42 4d 8a 0 0 0 0 0 0 0 7a 0 0 0 ::end of BMP header:: ::begin of DIB header (108):: 6c 0 0 0 2 0 0 0 2 0 0 0 1 0 18 0 0 0 0 0 10 0 0 0 13 b 0 0 13 b 0 0 0 0 0 0 0 0 0 0 42 47 52 73 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ::end of DIB header:: Bits per pixel: 0x18 Color Planes: 0x1 Bitmap Width: 0x2 Bitmap Height: 0x2 ::begin of pixel array (16):: 1 1 fe ff fe fe 0 0 ff 0 0 1 fe 0 0 0 ::end of pixel array:: 

The issues I'm having involves the pixel/color data of the pixels not being entirely consistent with the original image file.

There are four bytes for each pixel within the pixel array (although I believe there is a 1-byte padding on each set of 4-bytes for 24-bit RGB BMP files to keep consistent with 32-bit RGB BMP files which keep track of alpha values), and since the BMP image file that I'm using is the provided "colors2.bmp", which matches the image file that the Wikipedia page provides, there really should only be 4 rows considering there is only 4 pixels to the entire image.

The first row reads correctly if I use the first 3 hex numbers to construct a RGB color (0101FE produces an almost entirely blue color, which is 0000FF). However, the second pixel should be either green (00FF00) or red (FF0000), but it's neither: it's yellow (that's if I follow the pattern of using the first three bytes from every line to construct a color, it makes white if I use the next sequential three)...

I'm almost positive that I'm reading in the byte information from the file correctly, especially since if I read even one more row from the end of the file, the output will stop showing these nice pairs that I have and replace them with FFFFFFF in place of the small 2-digit hex numbers that I have now... if you would like to try it, just add another row of:

read_bytes(4, fp, NULL); 

to read an additional four bytes from the file, it should produce weird output.

Does anyone have any pointers on why I would be receiving incorrect pixel data? Am I simply intrepreting my results incorrectly? I would appreciate any and all help with this since I've been stumped for a few days as to what the hell is going on! Thank you so much!

submitted by /u/cdrootrmdashrfstar
[link] [comments]

[C++] Converting Infix to Postfix Issue

Posted: 16 Aug 2016 10:21 AM PDT

Hey quick question,

Trying to create a reverse polish notation calculator using stacks and queues and whenever I run my program, when it should give me the converted postfix expression, it's just blank. Any help is appreciated:

#include <iostream> #include <stack> #include <string> #include <queue> #include <stdlib.h> using namespace std; int main() { stack<char> opStack; queue<char> postQ, infixQ; char t; cout <<"This is a Reverse Polish Notation calculator!" << endl; cout <<"" << endl; cout <<"Please enter an infix expression to be converted into postfix:" << endl; cin >> t; while(!infixQ.empty()) { t = infixQ.front(); infixQ.pop(); if (isdigit(t)){ postQ.push(t); } else if (!opStack.empty()) opStack.push(t); else if (t == '(') opStack.push(t); else if (t == ')') while (opStack.top() != '('){ postQ.push(opStack.top()); opStack.pop(); } opStack.pop(); } while (!opStack.empty() && opStack.top() != '('){ postQ.push(opStack.top()); opStack.pop(); } opStack.push(t); while (!!opStack.empty()){ postQ.push(opStack.top()); opStack.pop(); } string y; y = postQ.front(); cout <<"Your postfix expression is : " << y << endl; } 
submitted by /u/monkeyapplez
[link] [comments]

0 Response to "[Tutorial] Learn to make a game in C++"

Posting Komentar