
Welcome to this new Python series in which we will be learning about Kivy, which is a python library used for developing games and mobile applications. The benefit of of using Kivy is it's cross application development, that is, create once and you ill be able to run it on Windows, Android, Mac, iOS
In this video, we will create our first Application Window and add Canvas widget to our app. We will be creating the window using 4 a step process - 1) Create the App 2) Create the Game class 3) Build the App 4) Run the App
In this video, we will start creating our Kivy game ( Ping Pong Python). We will start by adding a rectangle and some text to our window.
In this video we will be adding the ball to our Pong Game Creating the Pong Ball - - self: always refer to the current widget - Size not in ellipse size because when drawing outside it takes the center as reference but when drawing inside canvas it takes left hand side as reference Steps 1) Create the PongBall class 2) Create the PongBall rule 3) Add the PongBall Widget inside the the PongGame Widget and center it Moving the ball - Prepare - NumericProperty - Tell the program that this is a number. Python might need it but if this program is going to run on as a mobile app it needs to know whether is number is an integer or not. Because programming languages like Java are based on it - ReferenceListProperty - To change or get both of these values at the same time - Difference between speed and velocity - Velocity also has directions. And to get the direction we need to convert it a vector - Latest Position = Velocity + Current Position
All right guys, Welcome back, in the last video we learned how to add the ball in our game, using kivy. In this video we are going to learn the movement mechanics inside a game. Basically the logic behind moving an object inside a game. And In our case, it's a ball. So currently you can see our ball is at Position A with x and y co-ordinates as (25,50) and our goal is to move the ball to Position Z whose coordinates our (75,50). So according to the coordinates you can see we are moving the ball currently only in the x direction. That is, from left to right. But we can't just directly add 25 to the x coordinate in our current Position that A, otherwise it will just look like that the ball has teleport-ed from A to Z. That is why we have keep adding one pixel at a time, or it can be 2 pixel or even half a pixel, just make sure that amount of pixels we are adding are constant and small. This addition will make sure that the transition is smooth and it looks like the ball is actually moving instead of just being teleported. And if we keep adding pixels our ball will eventually go from Position C to Position Z. And this happens because of our eyes. Our eyes just can't keep up with the speed at which which we are changing the ball so it looks like the ball is actually moving but we are just changing the position of the ball. This is how actually videos are made. Videos are just a bunch of images in which objects change there position gradually. Each of these images are knows as frames. Similarly you can think of our game as a bunch of images. Each image is moving the ball by 1 pixel. Now our game speed is dependent on how many images we can show in 1 second. And that is also know as frames per second or fps. If you increase the fps the speed of the game will increase and and vice-versa. We will changing this fps by something known as the Clock Method inside Kivy, which we be will writing the code of soon. So here is our step by step plan - First we use the clock method to define how quickly the game should run. And it will also call the update method Second, we create the update function. This update method will run 60 times in 1 second or 60fps which we have already defined in clock method. Then finally this update function will call the move function, which we created in the last video. I know, this might a little bit too much of theory but feel free to go through the video again if you didn't understand anything but I am sure that as we go on to coding the theory will become much more clear.
In this video, we finally start to move our ball. Steps to first animation - Create the ball object Property - Add the id in in PongGame .kv file ObjectProperty - Just like NumericProperty we are tell the program that is an object variable inside a class Why we need need linking up? Explain the flow Have a look at the PongGame class - Look inside kv file & create the ball -Look at object Property Go again inside kv file to find this 'ball' Object property - After finding it, it will see what ID does refer to? It will further inside and find the id and thus hooking up the ball objectproperty to the pongball inside pong game. Now if we change anything in the ball it will automatically change our drawing of the PongBall inside the PongGame Moving the Ball 1) ball.move inside the update -self.ball.move() 2) serveball() - self.ball.velocity = Vector(4, 0).rotate(randint(0,360)) 3) Change the return PongGame() to game
In this video, we will start creating our Kivy game ( Ping Pong Python). We will start by adding a rectangle and some text to our window.
In this video, we will be creating the Paddle Graphics.
Alright guys, welcome back. We are going to be covering touch events and how to move our paddles by using our mouse as well as touch screen of our mobile phones. # on_touch_down() - When our fingers/mouse touches the screen # on touch_up() - When we lift our finger off the screen after touching it # on_touch_move() - When we drag our finger on the screen So There are 3 ways to detect and react to touch on Kivy. First is the on_touch_down function - Which is automatically called when we touch the screen with our fingers or with our mouse. And when we left our finger off the screen then the on_touch_up function is called. And third is the on_touch_move function which is called when we keep touching the screen and drag our finger across the screen without lifting it. A great example of this function is swiping right on tinder. You drag your finger across the screen in one clean motion. To move our paddles up and down we will be using the on_touch move function() So we will go inside our PongGame class. Create a new method inside the update function because we need to check continuously whether the screen is being touched or not, and we are going to call it on_touch_move function. It will take two arguments, first is itself like every other method inside a class. and second is the touch. This touch argument will contain all kinds of information. For example the x and y coordinate of where we touched the screen. Now we will need to tell our code two things, firstly what to do if the screen is touched and secondly where is the touching allowed. So in our game we will only be allowing the paddles to be moved if the touch happens before the score text for our player left, which is approximately 1/4th of our game window. And similarity for the player right, we will only allow touch after the score text. Whose x coordinate will be almost equal to 3/4th of the screen. So inside our on_touch_move function we create an if condition for our left player, which checks whether the x coordinate of where we touched the screen is less than 1/4th the screen or not. We are basically comparing x co-ordinates. And if this true then we will move our paddle to the y coordinate of where we touch our screen. We do this by making the center of our paddle, which can be referenced by center_y equal to the y co-ordinate of where we touched the screen And similarly we for right player we check whether the x coordinate of where we touched the screen is greater than 3/4th the screen or not. We do this by multiplying the width our screen by 3/4. You have to remember that this actually a x-coordinate. I am just called it 3/4th of the screen to make it more understandable. And then if this is true we will again move our paddle to where the screen was touched. And then just like we did with our ball we are going to hook up our code with our kv file otherwise the paddle is not going to move. Because at the end of the day. kv file is responsible for redrawing the paddle in a different position. So we will will create two object-properties called player1 and player2 with their default values as None. And then inside our kv file we will add them inside our PongGame. So player1 will have an id of player_left and player2 will reference the id of player_right. We have already created these id's down below
In this video, we will be detecting the collision between the Paddle and the ball using Kivy Python
In this video, we will be working on the score of our Kivy Pong Game.
We will be converting our Kivy desktop app to an android app. We will be doing this by using buildozer which is used to convert Kivy files to apk.
Steps to convert Kivy to Android APK -
Note - If you are using Linux or Mac. Open up your terminal and directly jump to step number 4
1) Signup on Digital Ocean https://m.do.co/c/c2cf5bc2a760 - Use this link to get 100$ free
2) Create a Droplet
3) Open up terminal Access Console and login using you One-Time Password
4) Installing Python and Virtual Environment https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-ubuntu-16-04
5) Install buildozer - https://buildozer.readthedocs.io/en/latest/installation.html#targeting-android
6) Install Filezilla ( skip if Linux or Mac) - https://filezilla-project.org/download.php
7) Connect Filzilla to server ( skip if Linux or Mac)
8) Upload your kivy folder to enviroments folder ( in linux/mac just go to your kivy folder using terminal)
9) buildozer init
10) buildozer -v android debug
11) Using Filezilla download the apk in your bin directory
12) Copy this apk file to your phone
13) Run it. ( You need to enable install apk with unknown sources)
Welcome back you python developers, we just completed our Pong Game in which we covered a lot of essential basics of Kivy. From this video we will start building a new app called Paint. You will be able to draw on your screen using different colors create new shapes. We will be refreshing a lot of topics that we have already covered and learning a lot of new ones. One of my childhood dreams has always been creating my own paint program. Kind of like the MS paint of Microsoft which we all have used at some point. And BTW If are new to this Kivy series ill highly recommend going and watching the the Pong Game series first. Because we covered a lot of basics over there. 1) Installing Kivy 2) Creating the app,build, Widget, run
In this video we will be learning about # 1) Changing Background color and RGBA Colors # 2) on_touch_down # 3) Color # 4) Drawing a circle/ellipse
In this video, we will be drawing an ellipse/circle whenever the screen is touched by fingers or the mouse is clicked.
In this video, we will be drawing with our brush whenever our mouse is dragged on our Paint Window.
In this video, we will be creating a button that clears the screen so that we can paint on it again.
Have you ever wanted to create mobile applications/games using Python but had no idea where to start from? May be you even know how to code in Python but typically Android apps are created using Java and iOS apps using Swift
Here Kivy smoothly slides in and enables you to code once and create applications for not only mobile but also for desktop. With 17 videos this course is designed to provide a solid foundation in Mobile and Game Development using Kivy.
You will also learn (BONUS) :
Create desktop applications with Kivy
Convert desktop applications to Android using Kivy
Game Mechanics
Touch not only with mouse but also with you fingers for mobile
Source Code - All source code shown in this course is also available for download. Students can create their own projects using the downloaded Python files.
Why choose me as an instructor?
When i was a kid i saw this YouTube video on how make a folder invisible on Windows I was so fascinated with this idea. Since then my love for technology has only grown. I understand the people who are passionate about learning new things. At the end of each section we will take a quiz to check up on your skills and see if we’re ready for the next section. We will create this project together from start to finish.
So, why wait? If all this sounds great to you, Press on “Take this Course” and I will see you inside the course!