Full Title: Flappy Bird - Lecture 1 - CS50’s Introduction to Game Development 2018
Highlights
games andin the similar vein are illusions in thesense that a lot of the perceivedvastness and perceived complexity ofgames is often just due to cameratrickery and more because of limitedhardware ()
Note: This text is discussing how games and similar experiences are illusions created by camera trickery and limited hardware, making them appear more vast and complex than they actually are.
this is our version of flappy bird wedidn’t use the same exact sprites forcopyright purposes but we note that wehave a bird in the middle of the screenthis bird on click or on spacebar willjump up and down and your goal is toprevent the bird from touching eitherthe pipes or the ground itself and everytime you make it past a pair of pipesyou will score a point as soon as youtouch a pipe or hit the ground game is
over ()
Note: Game idea: similar to flappy bird but set in orbit around a planet with more newtonian physics. The goal is to go around the planet avoiding obstacles.
New highlights added December 27, 2022 at 11:52 AM
we wanta foreground and a background becausenotice if we go back to the slides wecan see in the very background we have a
sort of hill landscape and then on thebottom we have a ground and they’re thetwo of those are going to eventuallyscroll at different rates it’s becausewe called parallax scrolling ()
Note: Parallax scrolling is the technique of scrolling two images at different rates to create the sense of motion.
people create stages in real lifeto make you feel as if you’re in a whenyou go to a play feel like you’reactually in a scene but you know they’veclearly cut as many corners as possiblebut it works in the game you can’t telland that’s very common in gamedevelopment and something if you’retrying to achieve a particularly grandeffect it’s something to think about ishow can I make it seem like I’m doingsomething but I’m actually not how can Imake it seem like I’m a bird flyingthrough an infinite series of levels butI’m actually not we have a lot of sort
of more of that to show coming up soonwe have so so far we have our backgroundbut we don’t have the title character ofour game ()
Note: cutting corners to make a game work, and provides an example of making something appear to be happening, like a bird flying through an infinite series of levels, but actually not.
Similarly we can see games like Resident Evil or other first and third person games where the effect of large scale maps is created by only rendering the parts of the world we can see, thus saving significantly on memory.
has this functionloved key pressed which takes a key andthat will trigger it but we can’t accessthis outside of this function because ifwe define this function in bird Lua
it’s gonna overwrite this implementationand we don’t necessarily want to have toworry about other files overriding thesefunctions because who knows if you’re ona team especially who knows whoseoverwritten loved key pressed in whatmodule and what order does it get loadedin and what functions actually validwe’re gonna take care of this problem bygiving ourselves the ability to test forwhether a keys been pressed on the lastframe by implementing a function that weare also adding to the keyboardnamespace the keyboard table ourselves
called was pressed is going to take akey and all it’s going to do is checkthat table that we created before it’sgonna say if love keyboard keys pressedkey then return true else return falseand you could actually just return lovekeyboard keys pressed key and it’ll bethe exact same thing and so what this
has the effect of doing is saying okaybecause on the update which we’re aboutto see actually I should probably dothat before so that’s all it gets tiedtogether love dot at the end of love dotupdate we’re gonna do one last thing andthat’s reset that table because we wantto just check frame by frame so we havewe have a table a global table thatwe’ve created to check for whether keyspressed we have a callback function thatlove to digas us that allows us to do
that so every time a key gets pressedwe’re going to just add that key to thattable and set it to true now we can justsimply query that table anytime we wantto with this function that we’ve createdcalled love keyboard was pressed keywhich means on the last frame was thatkey pressedbasically return whether it’s true orfalse now the only problem is we’re notflushing it we’re not ever setting thatto false that is the effect of if wejust press all the keys in our keyboardthose will always be false always betrue until we reinitialize the table to
some empty value which is what we dohere on the update which takes placeafter all inputs been detected we’regoing to just set that table to an emptytable again and on the next frame it’sgoing to whatever keys we pressed thosewill get set to true and then we canjust query that table here as needed andany update henceforth so does anybodyanybody have any questions as to howthis is operating and so the ultimate
driving factor for us as to why we wantto do this we want to put in the work tosort of keep track of this global inputtable is so that we can actually queryinput single key input based on ourbased in other files outside of mainLowabecause currently all we can do to checkfor single key presses is look in maindot Lua but that’s not what we want todo we’re gonna go ahead and go to our
bordello ax and in our update functionthis is where we actually get to use ourefforts and say if love keyboard thatwas pressed space which is the key thatwe want to actually allow us to jump ()
Note: We have a special function called “love.keyboard.wasPressed” which will tell us if a certain key was pressed on the last frame. This way, we don’t have to worry about other files changing the way this function works. Every time a key is pressed, we add that key to a table and set it to true. We can check this table anytime to see if a certain key was pressed. To make sure the table is always up to date, we reset it at the end of every frame. This way, we can check if the space key was pressed so we can make the character jump in the game.