Skip to 0 minutes and 15 seconds Throughout this course, we learned a lot. We looked at data types, loops, functions, conditionals, algorithms. We’ve seen a lot. Now, a small exercise– something that I like to do when I’m playing games is to think about how have these developers actually created this game? Find a game you like to play. Play it a little bit, and then think about how the developer has created this. And write it down in the comments here. Here’s a game I like to play. It’s called RuneScape. I made myself, so I know I am cheating a little bit here myself. I know how I created it. But let’s use it as an exercise anyway. Let’s focus on the runes.
Skip to 1 minute and 0 seconds So we’ve got this layout of runes. Well, the easy way to use data structures, to see them, will probably be using a 2D array, because the layout is 2D, after all. So what I’ve done here is I’ve actually a 2D array of integers. And I then translate the integers into a rune. So if it’s a 1, it might be the rune that is looking like an arrow. If it’s a 2, it might be the rune that’s looking like a dragon. And in that way, I get from an integer to a rune. When the user presses the screen, first of all, we’ll check to see if he’s pressing a rune, and if that rune is to the side.
Skip to 1 minute and 46 seconds If it is, we will store it and remember it. Next time the user presses the screen, again, we check to see if it’s a rune and if that rune is on the side of the board. If it is, we then check to see if the type of rune that he has pressed is the same time as the rune that he just hit before. If they are the same, well, then we’ll give the player a score and we’ll remove both of the runes. And we are then ready for our new go. So go on and find your game, the game you like to play, and try and do the same.
Karsten talks about games he has played (and created) and encourages you to think about how game developers have created games using programming constructs.
Chose a game and have a go at deconstructing it. How do the actions in the game relate to the instructions in the code?
Note: A 2D array can be imagined as a set of arrays, or a table with rows and columns with each row representing an array. In programming, developers use multidimensional arrays as data structures. This is something you may wish to look at after the course. If you’re interested in knowing more you can refer to the Java documentation and tutorials, such as Java for Complete Beginners.
© University of Reading