Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Thursday, 19 March 2020

Chapter 12 // Exercise 4 - Principles & Practice Using C++

In this exercise I am using Visual Studio 2017 and the graphics files found here:
https://github.com/l-paz91/principles-practice/tree/master/Graphics%20Files

Chapter 12 // Exercise 4

Draw a 3-by-3 tic-tac-toe board of alternating white and red squares.

Github: https://github.com/l-paz91/principles-practice/blob/master/Chapter%2012/Exercise%204

I got confused on this just because I started over-complicating it. I started thinking of creating it as 8 lines that intersect but pondered about how to colour the parts in-between. Instead I decided to create a function that creates and fills a rectangle with just the top left co-ordinate given. 

I also don't like how set_color() means set the line colour. To me it's quite ambiguous and alludes to the fill colour more.

Another thing, you can't return any object that is a type of Shape as its copy constructor has been explicitly deleted. MSDN says people do this to prevent behaviour that they don't want but in this case I can't see why creating a rectangle and then returning it would be so heinous. Clearly it was done for a reason, however, I decided to be naughty and commented out the line in Shape (in my files it's lines 176 and 177).

After a frustrating 20 minutes of nothing appearing I was ready to just give up and do it the long way, however, when stepping through the code, the rectangles were being created and attached to the window in the for loop, but, on the last rectangle all the values got cleared in the window and therefore nothing was drawn. For some reason a range-based for loop 'resets' the window's shapes. I think it has something to do with Shape's default destructor being called as r will only be in scope during the loop. Anyway, a standard for loop works fine and we don't have to repeat rectangle code constantly.

(16/08/2021 - Note from future me...it didn't work because you allowed it to use the copy constructor which had been deleted...creating a copy that goes out of scope.....)


Chapter 12 // Exercise 4 - Principles & Practice Using C++

(This is very umbrella looking.....)

Sunday, 24 June 2018

Blog Update// Current State of Affairs

Well, the second year of my degree is officially over. I can't believe it's been two years already. It feels like yesterday when I decided out of the blue to become a programmer and start learning C++. I now have a foundation degree in Software Engineering & Game Development, but I'm doing the one year top-up to achieve a Bachelors degree. Even though I have the entire summer ahead of me, I've already started work on my dissertation as I've chosen something rather ambitious.

The past two years have been something of an eye opener for me. I initially chose the course because on the second year it included a module on modding games engines and for me this sounded like the perfect job. It made me think of game mods like the Skyrim Thomas the Tank Engine or various GTA5 mods (like this hilarious one showcased by Funhaus, I've watched this a thousand times and it never gets old). However, when I eventually got to this module after a year and half, I absolutely detested it. We had to use Unreal Engine 4 and create a game within a team of 5. I can now say with absolute certainty; that I detest Unreal Engine with a burning passion. I also don't particularly like 3D modelling or creating game assets which is half the point of being a games developer. I find these aspects to be tedious and boring. 

My problem I suppose is that the first language I learnt was C++ but in a C-style. Principles & Practice by Bjarne Stroustrup is an excellent book for learning C++, however, by learning it in a C-Style, I have come to hate object orientated programming and much prefer the old procedural style that had to be used with older languages. My favourite module of the second year was 3D games programming in which I used DirectX9 and C++ to create a simple StarFox (1992) clone. My tutor was exasperated with me because I created my own procedural engine instead of utilising his fully object-orientated engine. He likes to remind me that having my engine code and game logic so firmly tied to each other is not a good thing. I tend to counter with the fact that no-one but me should be using my engine so it shouldn't really matter. However, if I plan to get a job with a games company, my style of programming will clearly become a problem. 

So, all of these experiences have forced me re-evaluate exactly what it is I want to achieve from programming. I love writing code, I honestly cannot see myself doing anything else now that I've started, however, I'm not sure if I can see myself becoming a games developer (apart from in my spare time). That is why I have decided to go on after my degree and complete a master's degree in computer science to broaden my programming field.

For my dissertation, I've chosen to create a games engine for the Super Nintendo utilising the SuperFX chip, as I find it extremely fascinating. I've already started learning Assembly x86 and have found it to be a more enjoyable language than C++ because it has to be done procedurally. I actually really love it. After I have grasped the basics, I'll be going on to learn 65c816 ASM, which is the microprocessor used in the Super Nintendo (or well, the Ricoh 5A22 is used in the SNES but it's based on this particular chip). I've been told this is a particularly difficult language and should not be used to learn Assembly off the bat, so I chose x86 instead. 

So far I've found this task to be challenging and rewarding, far more so than choosing a more game-related subject. Therefore, I will continue to post exercises from Principles & Practice as I complete them but it is not going to be my main focus (as I thought it would be). Learning Assembly and finishing a DirectX11 engine in preparation for my final year is going to be my main priority. Thank you to all those, who visit this blog though and who knows where I'll be a couple more years down the line.

Saturday, 24 February 2018

Where does the time go?

So my last post on this blog was the 1st of June 2017. It's disheartening to see I only posted twice last year however I found my first year of uni a little overwhelming. Since the last post I've completed my first year and I'm now four months away from completing my second and receiving a foundation degree. I'll definitely be doing the honours top-up to receive a full bachelors degree next year however the course I'm doing is heavily focused on video-game design with some programming involved. Over the past year and half I've realised that I much prefer programming over making games. 

With the industry moving towards making games in pre-made engines such as Unreal, Unity, CryEngine or their own in-house engines like RAGE and Snowdrop it would appear the art of programming a game from absolute scratch is a thing of the past. Sure you can but it's something that indie devs would do and if you're an indie dev (like I wanted to be) it's hard to complete a full game without the use of an engine like game maker whilst paying the bills. 

I've become a big fan of C and procedural programming as it follows how my brain works. I like to make lists and follow those lists; ticking one task off at a time. Object-Orientated programming is more than a little confusing to me as it jumps around all over the place. I recently just finished implementing a font class for my DirectX 11 engine and the amount of times I had to go back and change function declarations; create new functions or just redesign the entire thing entirely did my head in. Perhaps it just goes to show how weak my C++ skills are right now, I'm certainly more comfortable writing class interfaces now than I was a year ago. A year ago, trying to implement code from MSDN seemed impossible so perhaps I'm just being impatient with myself.

I've decided to do a masters degree in Computer Science once I've finished my bachelors as it's more geared towards data science, memory management and general programming which I'm much more interested in now. The past year of my degree has been filled with writing game design documents, researching mobile input methods and 3D modelling; the latter I detest with a passion. I'm also not a big fan of Unreal and I find it dissatisfying to have to use it constantly throughout my degree. I am however enjoying building my own engine using C++ and DirectX, there is just something about writing code and clicking the build button and it compiles with no issues.

I took this blog off google for while as I wondered if I should continue it, however I am determined to finish this book and his next one which is for more advanced C++ programmers. I will begin re-posting however at a slower pace as I have many deadlines looming. I would like to finish this book by the end of summer though. Thank you to everyone who drops by and I hope someone finds these posts helpful.

Sunday, 27 November 2016

Little Hiatus & Blog Update

This blog is currently on a small hiatus as I focus on university work. I am currently half way through chapter 7 but my assignments are top priority.

I just handed in my first which was Maths & Physics for game play which focused on parabolic trajectories and IK Chains and have a programming one and another maths due by Christmas. Whilst doing my assignments it has made me think about the future of this blog and would love eventually to put up tutorials on maths for games programming and c++ tutorials. 

As someone who has been programming for just under a year, I'd like to keep the topics on this blog simple, especially for beginner programmers. I've found that newbies asking questions in places like stackoverflow or cplusplus are met with patronizing answers from 'experts' whose answers are way too technical for their level of understanding. 

For example, someone had posted a question on an exercise from chapter 5 of P&P on stackoverflow (I was searching for an answer myself and I was stumped) and one user replied with "just use maps". Another user then had to point out that maps aren't introduced till a much later chapter (I'm currently still trying to wrap my head around classes). I guess what I'm trying to say is, I want this site to be a place where newcomers to C++ can learn the basics without the fear of experienced programmers thinking they're stupid. 
     We all learn at different paces and in different ways. I still use system("pause") every now and then despite what every single user on stackoverflow says. I only ever use windows and it works for what I want. Would I use it in a professional program? Of course not, but that doesn't mean I'm idiot for using it. You have to learn to walk before you can run. That's why Bjarne provides you with a header file with functions such as keep_window_open(). That function works in exactly the same way as system("pause") but for the first few chapters I had no idea how it worked, I only knew that it kept the console window open (as visual studio has a habit of closing the console window when the program has finished executing). Now I understand how it works and how to create a function which does the same thing. 

I am in no way an expert, I'm still learning, and have a lot to learn, but this blog was created because I could not find any help on Principles & Practice. There are a few blog posts and Bjarne himself has answered a few questions but there doesn't seem to be anyone who actually goes through their answers and how they got them. Therefore I hope that someone else finds this blog somewhat useful, if not I'm pretty proud of how far I've progressed so far. But enough rambling, thank you to those who are dropping by and if you have any questions I will try to answer as best I can.