Easy programing: your first iOS game. | Irina Galkina | Skillshare

Easy programing: your first iOS game.

Irina Galkina, Easy programming.

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
7 Lessons (48m)
    • 1. Intro

      1:00
    • 2. Set up environment

      1:27
    • 3. Xcode project first touch

      8:52
    • 4. Create a game scene ... without a line of code

      12:18
    • 5. The code: part 1.

      13:59
    • 6. The code: part 2.

      4:07
    • 7. The code: part 3.

      6:05

About This Class

We play games on our iOS gadgets every day and now it is time to create your own game!

 

On this class we will create simple classic game “Breakout”.  I bet you played this in your childhood.

We will start from downloading development tools and will see how to create this game on all stages.

 

In this class you'll learn:

  • how to setup development environment(download Xcode and start your first project);
  • basic structure of the Xcode project;
  • the basics of Swift 3 programming language;
  • what is the Sprite Kit and how to use it;
  • how to add objects to your game scene without a line of code;
  • how to arrange interaction between game objects;



Our program will extremely short and will include about 50 lines of code.

Each line of code will be explained.

You don’t need any programming experience for this class.

All source code created at this class will be provided.

Transcripts

1. Intro: Hello, everyone. Welcome to this class. My name is Serena and I am I developer. So at this plus, we're going to create simple Iose game. There is such a point of use that Iose Development is very difficult area about this class will create games that holds only 50 lines lines off court, so it could be an excellent start point for you. We will start from downloading big scope. We'll see how to game object automatically by interface builder and who will see how to connect this game. Object musicals. It's a game that we're going to create Watts and now very popular. It's named Break Out and I think many of us played it in our childhood. 2. Set up environment: Hello, everyone. Hello iPhone lovers. And let's just start our developing off office Iose game. And for this purpose is for developing for isles developing. For Marcus, we need X code. X Court is the instrument for developers. It has a lot off different and developer tools and we need to do a loaded from Webster just goto Webster and type X code and human. You can see that we have this. Yep. Also, I can recommend you the one book fall Speak line, which is the Smith the program England, which you condone. Load it from iBook and you can you can use it is a dictionary for different terms for different situations. And if you have some think unclear, you can just go to this bill can make it clear in our project. Will you speak as a program in Quinn, which is Britain? Human bitches was created in 2014 and now we have felt the ocean off system, which and it's good to church to start your development and going. I was from this language because it's much Maurice is an objective objective C and much more developed. So good luck and have fun 3. Xcode project first touch: So now it's time to create our first fortune. And after you don't load it, ex court just opened in and you will see me new legs. That and just choose Great. Uche scored approach, uh, entries game here in type of application types because we're going to create our first small game. Next product name will be the name off our game. Let's coat some count. How? Break out team. Ah, it depends. Do you already have your developer account in Apple or not? So it's not necessary for our work, so just select none organization. Name it. Just type something. Maybe your Suning organization identifier. It will be like you're calm and your cell name organization into identify fire. Yeah, all in which all those lists 50 game technology is a sprite Devices universes. All these jig books should be unchecked and just click next here. Just choose directory when you want to save your exclude project. So I know. First project graded and here we have have different types off files. Obviously, here is our ex good project have two folders and in first folder in first in the unfold occult break out. We have a lot of different file types. Let's move on and say Ever say something about each filed up in your ex got project to know for what? All these files. So as you can see, we have here a lot off different types of files and let's do visit should be. Definitely. They will visit and say about each off this file. What do so first file empty the gate? What it wouldn't do in delegate is the swift trial. So it means the file with the sweet source Kat. And it's described behavior off the application when you go for ground background when it active or detective. So the main stages off application life. Ah, we have Sekar file Abdullah Gates. If in each application and often it doesn't change, it doesn't change anything ended file and for our project for our small going game, we don't need to change it toe else. So I have another two files. The Swift Extension games sin and gave you control. Gibson is the file with the sweet source code. When his magic is done, you can see that we have a lot of source cold here already. But old this source code written for application that we already have. And if we just run our simulator, we will see the supplication. We will do it in the end of this lesson and, oh, for our project. We just remove all the source court. But you should know that the Gimson sweep against Insert file is a file that describes behavior off the object of your game sense. So let's imagine that you have dog Azaz a first person in your game and game stain well describes the behaviour off this person. Uh, and so and so we have gave you controller and the controller is the controller off the game , son. It's defined when our gain stand should appear or disappear or changed should be changed or should refresh or everything connected toe our games and an hour application. Uh, here we have else. So initial functions about the screen orientation and everything. But for the first time, you just should know that game you controller is file said defines behavior off the Jensen . And so the other two types off file that we have here is that s que s and storyboard. This case file is the kind of magic file cause here we can create game since without a line off court. So here, that is the place where you just can drug and drop different game objects, said them different characteristics. Said some different parameters and parameters and don't need to write a lot. Don't need to write a line off court for this. So it's very useful file to create your own game now to create object off your game. Uh, was for lazy person toe. Add some objects of game and don't write a lot of good. So this is our world. Gimson Escape s also have action escapes, and here we can add some Imation's for our characters off our game, and also we don't use it in our game. But you should know just here we can add some animations for your characters. Else will have main storyboard in some kind off magic file, Truth on and it more useful in applications that not our games for just applications. And here you can add some kind of controllers buttons labels to applications. It can be don't quickly, and it's him and, uh else we have assets. He'll have resources like images, basically images, and here have else's lunch launch screen story birth. It's a storyboard for launch screen. So means the report is for the rest of application and the loud screens Colorable is for lounge screen and also in four, please. There are a lot of settings for application, like, for example, false, that will be used in your application or as one we will. We won't change it, but for information, you just know what it defiance what it fought. And let's start our feels ready created project that we have. And here I just chose chose ah, simulator type and I just chose I chose iPhone five s and just click plate. So I already have here. Such a beautiful application is this snake blue snake and all this behavior off all this snake movement off off label. Hello, world criticizing. It's all describe in our game sense swift file. So it's the end off our world. Listen, and we just head first touch with our export project 4. Create a game scene ... without a line of code: So let's just jump right in and go to the game. Send file to the games in this case and what can I see here? I see hair already created game Seuin So here I can see this sin and Sistan has Hello label as you can pretend this hello label is connected to the application to the game that we already have in preloaded in our ex called Project, So I just don't need it anymore actually, so I just breasts backspace and needed Sorry why I can do this, Did it? Yes. And now it's time to add our own dean objects s and just see here and you can see that we have a lot of difference gain objects like camera and also complicated the different game fields So but for our purposes, we don't need such a complicated objects. We just need to a kind of simple objects like square so rectangles. And for this we just need color sprite objects of simple subjects and I just drag drops this object to my game stand and I already have one object in my game. So if I select my first s cast right in this case bright note so saying in the spread kit technologists, Germans terms it means this this note everything. Every game logic is a note. So this is a note, and this is its features, its properties. You can see that there are a lot of D foreign properties for position for size, for Carla and for everything. All this properties is about external features about color, position or something like that on. But for our purposes, we need three chairs that connected resist physic body because we know we're not want to interact game objects between each other like a bowl touches break and bowl touches pedal, and we want all be done by your physic world spread kids physic forward. So first of all, we need to set forth this note. It's physics body characteristics. So once again, I have for now this game object like an me an image on my boat. So it just like a stick air, but it doesn't have its physical body, but for our game, it's about direction between objects. The physical body is the, uh, main made proper see off our game objects. Um, so I just go in the end off this features menu. Uh, I mean, it's it's here and I want to say physics definition. There are three below that fees excited types. It's abounding, correct and go So the physical body will be kind of brick tengo would be and as the one is abounding circle so the physic body would be like circle and every mosque and if was purposes If you want complicated form and you want your physical body to be a complicated to like you often it uses for images and just spread kids getting your image and create music body according toa image. So for my purposes and you just boned incorrect angle and I can see here a lot of different properties according to the physic body. So, uh, this four is the main purpose. Is main properties dynamic? It said, should my body be dynamic dynamic, What it means shouldn't be moved by other bodies should be moving. And because I just great here is break, so it shouldn't be dynamic. Hello, sir Station. This property means that should this body be irritated but by other bodies and for my purposes, there is no need to be irritated by other bodies, so I just And check it. It should be this body being and ah, for this game Send again. This not to be done and affected by ground with you, should it. But as his body be affected by gravity, of course. No, because otherwise this break we'll be just pulled out. So I just need toe has a physical body, but don't need moved on. You fall down, don't it, Toby, To do anything off this so I just unchecked affected by gravity. So we just great our first break, our felt fitting body Our first note, this physical body and else. So I want to change some external features off this body. I don't like this pride that right color I wanted to be like Saiz Onda else. So I want to change size off this body to be like this. And I want to say name for this note and it should be like a brick. So that's my first break. And also I want to copy and based his brakes tohave about maybe nine brakes. So I just pressed Common City Common three and I have a lot of such a breaks you can see here sing Blue line. This scene blue line is our physic body, actually, um so if it will be like Circo, it will be so cold. But for us, it's Rick. 10. Go! It's OK, so a few more and now I have nine. But, uh, didn't hinting like this, I think would be better. So it's my first double and breaks for the first level. And now let's at Kabul. So I just driven drug color sprayed as usual will say name Who's a bowl? And if I said by the type of course I need by the DYP like circle for my boat, you can see Zed sees sink line. It's circled now, so it's physical body. It's like circle. Actually, for my bowl I need a kind of image uh, Dextre for visible and already has it all in heaven are now. I just go to my desktop and here I can take this bowl PNG and edit like here to my images, essence is for images. Also, I have since here already preloaded spaceship spaceship model. It's a spread, kid preloaded image model. Excellent. So I don't need it in my game. Sorry, just it. Go back to the game sin and job it long and select off course your bowl instead, texture to the boat. So now it's became suckled. Maybe like this would be perfect. Yes, select this boat again. And what I should said for this buddy off course, I wanted to be dynamic dynamic because it should move should direct with bricks and his bottle. But I don't want to be affected for rotation, and I wanted to be affected by gravity. Her institution equals one because once again, restitution is about bounciness off the body, and our bow should be absolutely bounce nous. What does it mean? That means that after in directions that the bodies it with the same speed before interaction and for the bold we absolutely need zero liner dumping and angular dampened because this property is it's for simulating like air water, like a simulating for environment. But we don't need it. Our ball not moving in air, not moving in water. So for the ball, we should set this properties for zero and the category mask for this should be definitely too and collision. Moscow should different one here should be zero, and contact must should be one because it will indirect with the Brits, as I said before, and let just let our board pedal, just move here and not rotate. Change this ice to be like this. Maybe maybe a little bit shorter. Change color, maybe for blue name should be. But though and off course, we should add physics body its definition bounds and quick Danica off course. It should be not dynamic it shouldn't it Not supposed to be moved by other bodies Snow rotating and, of course, no affected by gravity. Friction should be zero or institution should be zero. So we already created our small game scene, and now it's timeto code. And next lesson will be about putting, Unfortunately, is it's not enough to create, Oh, the whole game. And we need to write some code, but it's not will be large. It will be about 50 lines off courts, so just great for the game. 5. The code: part 1.: so nine step. Now it's 10 toe coat and go to the game seen sweeped, and here you can see a lot off court already. But, as I said before, older scored is connected with the previous application about her label and these beautiful rectangles. We don't need it, actually, and let's just delete is this Fields? And everything is that did move function. So now it's time toe, goat and go to the game. Sing swift file and here consider a lot off coat. Already written for this application is this. Hello label and beautiful rectangles, and we definitely need it anymore. But let just eat what we have here we have here. Gejdenson, our class game sent class class is a reflection off our game sent that we created our interface builder by dragging the drug object. This is it's called reflection. So here we can have different fields for the label. Hello, label means and speaking old insists, was this blue rectangles. So what we have on our game send could reflect it in the class fields, and also there are a lot off different methods, different functions. The 1st 1 is did move, did move, function is for the thrust load and games and what should be done on the first loading off the game, Sam and as away as a others is for what should happen on different events like you touch your phone. Oh, you're moving your finger on your phone or you just and touching your phone and all these functions is about this. So touchdown, when you touch your phone touch, move when you're moving, touch up when you just pop your finger. So we definitely don't need this fields because it for previous application we need our own fields. We definitely don't need ever think that we're eating here because we have our own game objects again. We need touchdown method because we're going to touch our form, our screen and I knew dysfunction. But I need everything's that inside it and I don't need and I need touch moved off course. What a catch up and everything in this I don't need. So I just elated. Okay, so what we have here is a clean file is the through med. It's which we will need and Elsa Well, right. One more method. Foreign directions for handle interactions between objects and For now, it's pretty easy as a whole, as I hope so. Now it's time to right some quote by your own and let's great some properties, some fields for this game. Sin class. And I said before the properties is Ah, quickly, often is a reflection for the physic bodies that were created in the game sin so but which what visit by this would have on our game some bricks, bowl and pedal. So let's create Well, I said name bowl and I should said, type of cysts object. It should be definitely. And Scott s que s came in spreading it right Note, Uh, the question science means that it's not already defined. I will define it. It did move function. And the 2nd 1 is the pedal, which is definitely sprite no to So I has this toe properties him against sing oh against him Swift phone as a reflection off my objects game objects which I created in my game stand is SK s filed. So what I should now should do now in my did move function, as I said before, is a function which called on the 1st 1st cold when you load your game sense. I I should set visible ends a bottle. So I just said Bowl means self self. It means the game. Send this this class self child not because my bowl is the child off the game, son. His name as you. So before I said names for my bowl, bridal and break so boat. And of course, it is escape spray because we have different child knows it not be definitely should be s case right now, but it could be like another types off notes. And I said that Definitely Sprite, no. Also, the pedal is the same, but with a different name. Yes. So, as they said before, we use spread get physic world and our bodies like bull and but no look, we'll have physic bodies and we'll interact. Visit just mobile Won't you interact with freaks And I dont peddle Busan trick to baseball And we can handle this direction White because when bold direct with break, this break should disappear because when both touches break, it should disappear disappear And we want this class this game, son, handle such interactions. How we can do this just a full We should say this game, son Elsa is spread. Kid Physic World contact. Delegate! Delegate! So we said that this game Sen is in charge for handling such interactions and they can be charge Also, this It was said that it can be charged church and else. So in our didn't move method, we should definitely say that this class is in charge. Four assists and how to say this. So I said Like so, uh, physic world contact in the gate is self self. It means this game sent So these games and is in charge was this. So what next does the fall? I want to start my application and see what I have. Just press plate and we'll see our game. I was small, beautiful game, so he would have something and receive them. Nothing moving Nothing moving. And, uh, we should definitely change it and, uh, force both to be moved. So soap simulator and said Just bowl. But no bull. Ah, but it's physic body. It's all about physic body Apply impulse and we should create Dichter, which will use die x 15 end di Greek, The Greek dying Igric 15 to So what is about? We want our boat moves like from the left corner to the right corner and up for moving cup . We should say positive value for the Igric and we set 15. And for moving toe the right, we should set a positive value two x and with set 15 to Let's see what we have now and we see, is that our bowl slows rink. Sarif was slowing because I record a video and a little bit became a little bit slower Everything. And we see that our bowl just go away from the screen like bye bye and we definitely don't need it. Let's fix it. How can we fix it? We should say that I waas green borders is like strong and our bowl oh, should go from screen. So let's see, Bowler there s que physic body is his body ways is a age so really music body age loop from so from which form disfigured physical body will be created and we definitely knew need our screen How can we get over screen? We should say our view because each sing send has its own you sin and say free. So it's our frame off always green and we created such a physic buddy. Now we should say that bodies that direct with our screen shouldn't lose energy. It, like, will be absolutely smooth. So for this I should say fiction is zero and else So I won't say Is that physic body off? My sin should bay this board there. I pressed common Be to compile this project to see if I have some mistakes here. Have mistaken just press here and I can It could be automatically fixed, but it's code and I just use it function off X code. So now I will see that my screen It's no only transparent and in the bowl these interactive is this freight. 6. The code: part 2.: So now we need just move our battle by touching cover screen, and he would have to methods for a touchdown and Dutch move. And actually, it's not appropriate methods for us. On and appropriate will be another two methods, and you just can clean this and start to type over. Right Funk that just begun is, it's meant. Is this man that will be appropriate for us and is there as a one over right funk purchase ? Moved. So this Tamez it's is from game center and games and uses exactly that this message toe handle everything that connect beings touching. So the previous one of the previous two minutes waas wrong and this toe are right here in my touch has begun this method IHS we can see its name is in Boca bands that that's just begun. Eso here we just right cool Dutch in purchase and what it means. It means that for every touch in all touches that we have because you can know, touch your screen different places and we have several Duchess for every touch in since in all the statues. So we should say, First of all, we need to create location much. Look, we get our touch. I would touch object with the kindof recovery collection off this physical touching location and where location, vacation in our Jason, our game. Something. Our record. As I said before his self in self. So when we don't where when were we touch our Jason? My touching. I was good. So we have already education and the simplest one. We should said bottle like position picks it growth. But look six. Just press common being for Butte. Our project and our duchess moved, which interact When you move your finger on your screen, you should just a say hep justice ing just common. Be four. Build our project And let's just start was this game and it's a bit long and you can see is that Ah, what bad is moving cool? 7. The code: part 3.: and now they're just handle direction between our books and our brakes. Um, and for this, we already have appropriate method. Let's just type over, right? Funk it, baking What did begin The contact did begin between every object on our games and and here in the Met is this method we can handle is Andi said what we should do for our bricks and our book. And here we have only one object as a parameter contact. It's, uh, Webster object that holds information about this content about this contact between which bodies this contactar begin or different characteristic off this contact. So from this contact ah, object, I can get my anybody's. So I have body a contact apart in age because God took, we have Oh, what is but a anybody be so it could be pedal double a ball or break Or maybe pedal and a brake. But not for us. Because Minos a can can and drug visit Charles er so else. So I need ah, body be body be. And now I can check contact and collision masks for body. Be anybody a So Hi. How can I write it if by the age category Bit masked. Iqbal's equals is to prove equals one s we remember the one is the category Mosque off bull or break a break Yes, the category mask off a big And does this mean end such this means in the same time? Body be category Big mask equals two So he handled our situation When the ball touches the break we want with the brake disappear So I just see body a by the a no removed from parent so just disappear But he moved from burns removed from our world Games in And that's everything. Not everything. But we already can see. And actually, we don't need this off, Right? So let's just breast common being and start our project. So yes, you can see ah, what breaks removed by our bull and games He's going well, but also there is can be such situations that, uh but it is and body be they have can switch, which is out of so I just it and as a each state when here so but a category big mosque equals two. But category B category B could trigger bigness for by the B equals one. So in situtation body be should disappear from. I was green. So that's the whole court, that we will have this lesson in this class. And it's about 50 lines of code, as I said before. So we just wrote Simple, useful game. You can develop it as you want after this. So listen and can at some labels here can it. The maybe change speed can at different levels for this game. There are a lot of face how we can improve your game and enjoy it on your own phone. And you know that old game and start to develop the problem getting from this point. Thank you for watching this class and good luck.