Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
c0a6ded
objective
QifanGuo Mar 21, 2016
d2d2d70
Merge pull request #1 from jcho16/Danny
jcho16 Mar 21, 2016
38f55a2
Update README.md
jcho16 Mar 22, 2016
f19e975
First commit
Apr 13, 2016
534873a
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
Apr 13, 2016
e08a04a
Changed file name
Apr 13, 2016
3f73491
Imported Kivy
Apr 13, 2016
50bcf0b
Added KV file
Apr 13, 2016
450d4e4
Trying to make a background
Apr 14, 2016
b26b51f
Background works
Apr 14, 2016
fce369c
Tried to make backgournd move, failed
Apr 15, 2016
b15db71
first commit
Apr 15, 2016
910512a
Background works?
Apr 15, 2016
ea0754d
Made background move, not how we want it though
Apr 15, 2016
c19f2bb
Working background
Apr 15, 2016
ddc187f
Wallpaper scrolls better
Apr 15, 2016
68d33cb
start to the flappy bird, not yet displayed tho
QifanGuo Apr 16, 2016
4b7bb56
got the bird to fall, not yet fly
QifanGuo Apr 16, 2016
d4306b5
bird can flap!
QifanGuo Apr 17, 2016
2c1bbe5
fized background widget size
QifanGuo Apr 17, 2016
2bbb62b
flapping smoother
QifanGuo Apr 17, 2016
b44dca6
changes
QifanGuo Apr 18, 2016
d2b21f2
?
Apr 18, 2016
ee48843
first branch merge
QifanGuo Apr 18, 2016
91df56c
Fixed background image size
Apr 18, 2016
b740ee4
Made rock
Apr 18, 2016
e11b104
new character
QifanGuo Apr 18, 2016
a0ade51
??
Apr 18, 2016
4dbad26
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
Apr 18, 2016
fae266b
start to score label
QifanGuo Apr 18, 2016
4a234c4
working socre label, just need input data
QifanGuo Apr 19, 2016
c981cc5
Doesn't work (w/ obstacle)
Apr 19, 2016
22f9c62
jump better
QifanGuo Apr 19, 2016
31080c8
Start from scratch :(
Apr 19, 2016
4c35a3c
stops game when player outside window
QifanGuo Apr 19, 2016
9aa5193
obstacles'
Apr 19, 2016
25c1721
obstacles
QifanGuo Apr 19, 2016
a857c5c
With first obstacle
Apr 19, 2016
c8ed256
asdasd
QifanGuo Apr 19, 2016
8ee0734
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
QifanGuo Apr 19, 2016
67747d1
Merge branch 'master' into Danny
QifanGuo Apr 19, 2016
0707cfe
score increases by 1 every time u pass the 'bostcle'
QifanGuo Apr 19, 2016
18634c4
Better rock
Apr 19, 2016
2cac479
fixed obstacle stop glitch
QifanGuo Apr 19, 2016
efac6aa
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
QifanGuo Apr 19, 2016
3106144
Merge branch 'Danny'
QifanGuo Apr 19, 2016
a4578e6
??
Apr 19, 2016
cb672aa
??
Apr 19, 2016
779d73e
boundaries
QifanGuo Apr 19, 2016
a8b7142
New and improved w/ ceilings
Apr 19, 2016
a1aef10
....
QifanGuo Apr 19, 2016
ae813c9
falling speed adjustments
QifanGuo Apr 19, 2016
56efdcd
Fixed whitespaces
Apr 19, 2016
3d71bb3
collision?
QifanGuo Apr 19, 2016
357eff1
as
QifanGuo Apr 19, 2016
e68b3a6
Added obstacle1 (lazy version)
Apr 19, 2016
8143983
Minor tweaks
Apr 20, 2016
bb82fe7
Kinda sorted imports
Apr 20, 2016
cd33ea4
Removed random variable y
Apr 20, 2016
a47153e
fixed
QifanGuo Apr 20, 2016
9f3b951
realized bug in system
QifanGuo Apr 20, 2016
5db7e78
Changed obstacles
Apr 21, 2016
da96ffb
Changed obstacles
Apr 21, 2016
306e606
Changed obstacle width, there's still collision gap
Apr 21, 2016
aa7d2bd
Updated rock, added shitty water
Apr 21, 2016
9c60961
ads
QifanGuo Apr 21, 2016
a804b21
asdasda
QifanGuo Apr 25, 2016
a2a2e3e
Yay wallpaper
Apr 25, 2016
95bb379
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
Apr 25, 2016
60338ed
asdsa
QifanGuo Apr 25, 2016
edad936
Fixed-ish
Apr 25, 2016
7ce39cd
Merge branch 'master' of https://github.com/jcho16/ICS4U-PCP
Apr 25, 2016
28766f6
Deleted useless images
Apr 25, 2016
3336197
got hitbox working but with redundant code
QifanGuo Apr 25, 2016
026fd3d
hitbox adjeustments
QifanGuo Apr 25, 2016
b6c16fb
hitbox
QifanGuo Apr 26, 2016
b34f96c
Better pillars
Apr 26, 2016
9ce5393
Merge remote-tracking branch 'origin/Danny'
Apr 26, 2016
be7ddc5
Unbeatable :(
Apr 26, 2016
707104f
Whitespaces
Apr 26, 2016
80b7ade
Object one obstacle
May 25, 2016
ec37d1e
obstacles working yay
May 25, 2016
6952743
Planning main menu
Jun 1, 2016
888121e
beginggning of failure for menu screen
QifanGuo Jun 7, 2016
0ec7bed
umm tried using smart screen managaer and faield... continue later
QifanGuo Jun 7, 2016
cc5098f
revert to working version
Jun 9, 2016
3ceb885
not working
QifanGuo Jun 9, 2016
749c13e
back to working
QifanGuo Jun 9, 2016
2de5eac
umm menu exists but glitchy
QifanGuo Jun 9, 2016
82aafaf
menu working
QifanGuo Jun 12, 2016
09eac28
fixed values to make better
QifanGuo Jun 12, 2016
3645cd6
works
QifanGuo Jun 13, 2016
bbeed10
Menu added
Jun 13, 2016
8e4882e
Now with character in start screen
Jun 13, 2016
5b916bf
Fixed coordinates
Jun 13, 2016
8d242b2
Possibly final commit
Jun 15, 2016
9c64261
Final commit
Jun 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
215 changes: 215 additions & 0 deletions Game.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
import kivy
from kivy.properties import NumericProperty, ReferenceListProperty, BooleanProperty, ObjectProperty, ListProperty
from kivy.uix.image import Image
from kivy.vector import Vector
from kivy.app import App
from kivy.clock import Clock
from kivy.uix.label import Label
from kivy.config import Config
from kivy.core.window import Window
from kivy.uix.widget import Widget
import random
import sys


class Background(Widget):
image1 = ObjectProperty(Image())
image2 = ObjectProperty(Image())

velocity_x = NumericProperty(0)
velocity_y = NumericProperty(0)
velocity = ReferenceListProperty(velocity_x, velocity_y)

def __init__(self, **kwarg):
super(Background, self).__init__(**kwarg)
self.allow_stretch = True
self.size = (800, 600)

def update(self):
self.image1.pos = Vector(*self.velocity) + self.image1.pos
self.image2.pos = Vector(*self.velocity) + self.image2.pos

if self.image1.right <= 0:
self.image1.pos = (self.width, 0)
if self.image2.right <= 0:
self.image2.pos = (self.width, 0)

def update_position(self):
self.image1.pos = (0, 0)
self.image2.pos = (self.width, 0)


class PlayerObj(Image):
def __init__(self, pos):
# image properties
self.allow_stretch = True

self.source = "images/Box.gif"
self.size = (60, 60)

super(PlayerObj, self).__init__(pos=pos)

self.anim_delay = 0.25
self.velocity_y = 0
self.gravity = 0.2

def update(self):
if self.velocity_y >= -6:
self.velocity_y -= self.gravity
self.y += self.velocity_y

def on_touch_down(self, *ignore):
self.velocity_y = 6


class PlayerHB(Widget):
def __init__(self, pos):
super(PlayerHB, self).__init__(pos=pos)
self.size = (10, 10)


class Obstacle(Image):
def __init__(self, pos):
self.allow_stretch = False
self.source = "images/one_pillar.png"
self.size = (70, 700)

super(Obstacle, self).__init__(pos=pos)

self.velocity_x = -4

def update(self):
self.x += self.velocity_x


class Game(Widget):
background = ObjectProperty(Background())

def __init__(self, **kwargs):

super(Game, self).__init__(**kwargs)
self.background.anim_delay = 0.05
self.background.velocity = [-0.5, 0]
self.bind(size=self.size_callback)
self.size = Background().size

# player's object
self.player = PlayerObj(pos=(self.width / 4, self.height / 2))
self.add_widget(self.player)

self.playerhb = PlayerHB(pos=(self.player.center_x - 0.5 * 35, self.player.center_y))
self.add_widget(self.playerhb)

# obstacle
x1 = random.randint(250, 750)
x2 = random.randint(250, 750)
self.obstacle1 = Obstacle(pos=(900, -x1))
self.obstacle2 = Obstacle(pos=(1400, -x2))
self.add_widget(self.obstacle1)
self.add_widget(self.obstacle2)

self.obstacle1top = Obstacle(pos=(900, 820 - x1))
self.obstacle2top = Obstacle(pos=(1400, 820 - x2))
self.add_widget(self.obstacle1top)
self.add_widget(self.obstacle2top)

# score
self.score = 0
self.score_bool = False
self.scorelabel = Label(pos=(350, 460),
text="[size=40][color=ff3333]{0}[/color][/size]".format(str(self.score)), markup=True, )
self.add_widget(self.scorelabel)

Clock.schedule_interval(self.update, 1.0 / 60.0)

def size_callback(self, instance, value):
self.background.size = value
self.background.update_position()

def update(self, dt):
# collision stuff - window boundaries
if self.player.y <= 0:
self.player.y = 0
elif self.player.y >= self.height - self.player.height:
self.player.y = self.height - self.player.height
self.player.velocity_y = 0

self.playerhb.center_x = self.player.center_x
self.playerhb.center_y = self.player.center_y

# collision with pillars; the shape of the widgets needs to change to accurately reflect the collision
if self.playerhb.collide_widget(self.obstacle1) or self.playerhb.collide_widget(
self.obstacle2) or self.playerhb.collide_widget(self.obstacle1top) or self.playerhb.collide_widget(
self.obstacle2top):
if self.parent:
self.parent.parent.add_widget(Menu())
self.parent.remove_widget(self)

# update calls
self.background.update()
self.player.update()

self.obstacle1.update()
self.obstacle2.update()
self.obstacle1top.update()
self.obstacle2top.update()

# obstacle movement

if self.obstacle1.x + self.obstacle1.width <= 0:
x = random.randint(250, 750)
self.remove_widget(self.obstacle1)
self.obstacle1 = Obstacle(pos=(900, -x))
self.add_widget(self.obstacle1)

self.remove_widget(self.obstacle1top)
self.obstacle1top = Obstacle(pos=(900, 820 - x))
self.add_widget(self.obstacle1top)

self.score_bool = False

if self.obstacle2.x + self.obstacle2.width <= 0:
x = random.randint(250, 750)
self.remove_widget(self.obstacle2)
self.obstacle2 = Obstacle(pos=(900, -x))
self.add_widget(self.obstacle2)

self.remove_widget(self.obstacle2top)
self.obstacle2top = Obstacle(pos=(900, 820 - x))
self.add_widget(self.obstacle2top)
self.score_bool = False

# get obstacle pos in order to increase score instead of just this for testing, score update call
if self.player.x >= self.obstacle1.x and self.score_bool == False:
self.score_bool = True
self.score += 1

if self.player.x >= self.obstacle2.x and self.score_bool == False:
self.score_bool = True
self.score += 1

self.scorelabel.text = "[size=40][color=0266C9]{0}[/color][/size]".format(str(self.score))


class Menu(Widget):
def __init__(self):
super(Menu, self).__init__()
self.size = (800, 600)
self.add_widget(Label(center=(400, 275), text="Tap to start"))
self.player = PlayerObj(pos=(370, 295))
self.add_widget(self.player)

def on_touch_down(self, *ignore):
if self.parent:
self.parent.add_widget(Game())
self.parent.remove_widget(self)


class NameApp(App):
def build(self):
top = Widget()
top.add_widget(Menu())
return top

if __name__ == "__main__":
NameApp().run()
22 changes: 22 additions & 0 deletions Name.kv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Game>:
background: background
Background:
id: background
pos: root.pos

<Background>:
image1: image1
image2: image2

Image:
id: image1
source: "images/BackgroundS.gif"
pos: 0, 0
size: 800, 600
Image:
id: image2
source: "images/BackgroundS.gif"
pos: root.width, 0
size: 800, 600


Binary file added images/Background.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/BackgroundS.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Ball.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Box.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Pillar1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Pillar2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Pillar3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PillarA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PillarB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PillarE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/PillarT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Rock.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Water.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forest1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forest2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forest6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/forest7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/one_pillar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/platform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.