Game hit plugins, code & scripts from codecanyon

Journée Je Code: Objective sầu is khổng lồ introduce coding lớn teenagers using Python programming language ColorHit trò chơi Description Exercises To start: let"s understvà the game Exercise 1: Let"s start with the animation! Exercise2: Let"s understvà the graphics How does this works? Let"s play with the shapes! Exercise 3: Hierarchical widgets. Exercise 4: playing with for loop Let"s underst& how the variable works! Exercise 5: using if condition: let"s update the score! Hacking the game: It"s time lớn be creative! Watch out for bugs Installation on Windows OS


Journée Je Code: Objective is lớn introduce coding to lớn teenagers using Pynhỏ bé programming languageThe code is not pythonic as the objective is to introduce basic programming such as if condition và for loops.This code is not intended for commercial purpose.

You watching: Game hit plugins, code & scripts from codecanyon

ColorHit Game DescriptioncolorHit is a small cliông xã based game where the objective is to lớn score the maximum points:

the player can act on a small ball called anim_ball by clicking on the screenanim_ball can move sầu only on one direction on y axes (vertically)the display the click detection & animation are handled using kivy library.

The score is updated if the anim_ball hits a rectangle with the same color. If it hits a different colored rectanglethen the player looses one attempt. The best score is then saved. The save is temporarily as it is deleted if the playercloses the game window.

The game allows the player to change the color of anim_ball by hitting another colored ball that appears during the game.It is called color_ball. Anim_ball takes automatically the color of the color_ball on hit.

The thư mục demo contains the full game & includes some extensions that won"t be described in the exercises such as the freeze atthe beginning of each game start that allows the player to be prepared to lớn start the game or underst& that he losts allhis attempts và had lớn start again.


ExercisesThe objective is khổng lồ introduce coding as well as game programming.

The exercises are split in different folders where teenagers have sầu to lớn start from exercise_1 lớn finish with exercise_5.The exercises don"t contain the full game.

To start: let"s understand the game

The best way to underst& what you have to code is to play with the game to start thinking about the different problematics,và the game"s rules.

To exeđáng yêu the program run by using:

the command line python3 demo/main_solution.pyvia the editor"s run.You can play with the game! It"s a click based game so don"t forget khổng lồ clichồng in the game window.

cảnh báo that for all the exercises lớn run and see the code you need to lớn run from each execise folder.

Exercise 1: Let"s start with the animation!

In games there are two types of actions on the game widgets. (a widget is an object of the game example color_ball anim_ball ...)

either to give the control lớn the player (under some limitations)or it is your application that controls the widgets.In this exercise we will see the the cliông chồng based action where the anim_ball is animated on clichồng.

Here the objective is not to lớn code the animation but to lớn use a library that detects a clickthen automatically activates the animation.mở cửa it"s there the code to lớn modify.

First let"s explain the code.The header: lớn import the needed libraries or codes


init: to initialise the position in the game windowon_touch_down: the function that detects a cliông chồng and activates the function on touch down.


The objective sầu is to lớn modify to animate the ball to lớn bởi a realistic jump (let"s simulate the feel of gravity)If you try khổng lồ jump multiple times very fast the animation would be non smooth. the superposition of multiple animationsis not allowed we need lớn code this part. Use Animation.cancel_all(self) before the animation to allow multiple jumps

This what you could get without using cancel_all using different types of animations


The solution should look like this


Exercise2: Let"s understvà the graphics

This exercise is made lớn distinguish between the widgets used in code and the graphic lớn create the shapes of the widgets.Example you may noticed in the game we use multiple rectangles. In the code we use one widget for one rectangle as therectangles are independent objects where each one of them has its own kích cỡ & position.Those internal properties are used to detect hits.The choice of using one widget per rectangle is related lớn the hit detection as it is easy to lớn compare the position of the anim_ballwith each position of each rectangle (using internal properties).

But for the graphic no need khổng lồ create one shape for each rectangle!. We need only one!

How does this works?

When we want to create a widget (rectangle) we liên kết it khổng lồ the shape in graphic & then we can rescale it and/or change its position.

See more: Gift Code Game Chân Long Giáng Thế, Giftcode Game Chân Long Giáng Thế

Let"s play with the shapes!

open it"s the first part of the exercise2.


1- Add an image for AnimBall. use: source: ../images/cat_ball.jpg in Ellipse.You can play with source by putting personalized images. You can tải về your image và put it in images repository.Then use the right link: source: ../images/

2- Add an image for the Root. Use: source: "../images/cat1.jpg" in the right rectangle. Be careful about mixing colors(if we add màu đen with any other color it give sầu us black)

3- Add the text maxScore

4- ColorBall is missing lets code it ! we want a ball similar khổng lồ AnimBall

To understvà the use of widgets open and add another ClockRect

Exercise 3: Hierarchical widgets.

To change the color of anim_ball we need to connect the widget anim_ball & color_ball.We then check the position and then update the color. As anim_ball has to lớn be connected lớn color_ball but also the rectangles,we introduce a notion of hierarchy of widgets. Anim_ball becomes owner of all the other widgets. This gives rights khổng lồ Anim_ballto lớn access to lớn the internal properties of its widgets. It become easier to check if anim_ball hits a rectangle or a color_ball.

In this exercise we are looking at conditions: open The objective sầu is lớn code check_hit_ball.we need to change the color at collision.


Be careful with using equalities for games! The display of images và position checking are done frame by frame.We are evolving in a descrete time. If you put equal then it is very unlikely you get equal positions at frame display.In game coding try to lớn always use inequalities.

Here is an example: first video clip coded using == the second using


Exercise 4: playing with for loopThe for loop works as follows:


open we are changing add_rectangles. Run the code before modifying it. Only one rectangle appears.This is because in add_rectangles we put only one rectangle.

Use the for loop to add multiple rectangles (10 rectangles)

Use the variable nb_rectangles that specify the number of rectangles that we would like lớn display.

Let"s understand how the variable works!

Look at init in


In the initialisation there is a hotline khổng lồ run add_rectangles: add_rectangles(10). It"s variable nb_rectangles,is mix lớn be equal khổng lồ 10. We can then use nb_rectangles while coding the loop.

To check if you code it correctly change in the init add_rectangles(10) by add_rectangles(3) và then run the should see 3 rectangles instead of 10.

Exercise 5: using if condition: let"s update the score!Here is how the if condition works:


Open The objective is the update attempt và score. Here are the rules to follow:

1- The score increase if we have the same color of the rectangle and anim_ball

2- The attempt decrease if we don"t have sầu the same color of the rectangle and anim_balluse self.check_color(r) and self.check_collision(b, r.x, r.width, r.y, r.height) khổng lồ vị the updatesThe second file lớn modify is The rule to lớn follow:

3- if we find that attempt become less then 0 we should restart!In update_score_and_attempt update attempt. Use self.start() và self.attempt

Hacking the game: It"s time khổng lồ be creative!Keep in mind that the objective of creating a game is khổng lồ make it harder over time lớn keep the players playing.The objective is to change some rules of the game khổng lồ personalized it. You can change any tệp tin of kiểm tra.

Here are some examples of what you can do:




Watch out for bugsfor loop or if condition: don"t forget : after a for loop or an if condition.

Indentation is important: after a loop or an if condition, you need to lớn use a new indented line.

Read the error message: spover time khổng lồ underst& what it means!

Don"t hesitate lớn google the error message lớn better underst& your error and then know how to lớn fix it.

See more: How To Generate/Create Facebook Qr Code For Business & Personal Pages

If you are blocked you can find the solutions in Solution.txt

Installation on Windows OSThe application is written in Pyeo hẹp using Kivy framework.

1- Download or clone the projects locally2- Download and install Pydong dỏng (Anaconda) : with anaconda 3.5.03- mở cửa the Start Menu, and type Anaconda Prompt4- Change directory to the project folder5- Install all the dependency libraries- pip install -r requirement.txt

Chuyên mục: giftcode