├── icon.png ├── .gitignore ├── android.txt ├── sound ├── beep.ogg ├── reset.ogg ├── select.ogg ├── switch.ogg ├── explosion.ogg ├── accomplished.ogg ├── bullet_start.ogg ├── deflection.ogg ├── deflector_up.ogg ├── deflectouch.ogg ├── no_deflector.ogg ├── deflector_down.ogg ├── deflector_new.ogg └── deflector_delete.ogg ├── graphics ├── tank.png ├── brick1.png ├── brick2.png ├── brick3.png ├── brick4.png ├── bullet.png ├── goal1.png ├── goal2.png ├── goal3.png ├── goal4.png ├── rails.png ├── overlay.png ├── background.jpg ├── button_down.png ├── help_screen.png ├── tank_tower.png ├── accomplished.png ├── button_normal.png ├── deflector_blue.png ├── deflector_red.png ├── finger_point_white.png ├── stockbar_limiter_l.png └── stockbar_limiter_r.png ├── levels ├── level01.png ├── level02.png ├── level03.png ├── level04.png ├── level05.png ├── level06.png ├── level07.png ├── level08.png ├── level09.png ├── level10.png ├── level11.png ├── level12.png ├── level13.png ├── level14.png ├── level15.png ├── level16.png ├── level17.png ├── level18.png ├── level19.png ├── level20.png ├── level21.png ├── level22.png ├── level23.png ├── level24.png ├── level25.png ├── level26.png ├── level27.png ├── level28.png ├── level29.png ├── level30.png ├── level31.png ├── level32.png ├── level33.png ├── level34.png ├── level35.png ├── level36.png ├── level37.png ├── level38.png ├── level39.png └── level40.png ├── screenshots ├── banner.png ├── levels.jpg ├── gameplay.jpg └── settings.jpg ├── README.md ├── stockbar.py ├── tank.py ├── background.py ├── deflectouch.kv ├── deflector.py ├── bullet.py ├── main.py └── gpl-3.0.txt /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/icon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .pydevproject 3 | *.pyc 4 | *.ini 5 | screenshot*.jpg -------------------------------------------------------------------------------- /android.txt: -------------------------------------------------------------------------------- 1 | title=Deflectouch 2 | author=Cyril Stoller 3 | orientation=landscape -------------------------------------------------------------------------------- /sound/beep.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/beep.ogg -------------------------------------------------------------------------------- /graphics/tank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/tank.png -------------------------------------------------------------------------------- /sound/reset.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/reset.ogg -------------------------------------------------------------------------------- /sound/select.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/select.ogg -------------------------------------------------------------------------------- /sound/switch.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/switch.ogg -------------------------------------------------------------------------------- /graphics/brick1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/brick1.png -------------------------------------------------------------------------------- /graphics/brick2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/brick2.png -------------------------------------------------------------------------------- /graphics/brick3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/brick3.png -------------------------------------------------------------------------------- /graphics/brick4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/brick4.png -------------------------------------------------------------------------------- /graphics/bullet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/bullet.png -------------------------------------------------------------------------------- /graphics/goal1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/goal1.png -------------------------------------------------------------------------------- /graphics/goal2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/goal2.png -------------------------------------------------------------------------------- /graphics/goal3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/goal3.png -------------------------------------------------------------------------------- /graphics/goal4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/goal4.png -------------------------------------------------------------------------------- /graphics/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/rails.png -------------------------------------------------------------------------------- /levels/level01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level01.png -------------------------------------------------------------------------------- /levels/level02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level02.png -------------------------------------------------------------------------------- /levels/level03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level03.png -------------------------------------------------------------------------------- /levels/level04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level04.png -------------------------------------------------------------------------------- /levels/level05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level05.png -------------------------------------------------------------------------------- /levels/level06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level06.png -------------------------------------------------------------------------------- /levels/level07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level07.png -------------------------------------------------------------------------------- /levels/level08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level08.png -------------------------------------------------------------------------------- /levels/level09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level09.png -------------------------------------------------------------------------------- /levels/level10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level10.png -------------------------------------------------------------------------------- /levels/level11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level11.png -------------------------------------------------------------------------------- /levels/level12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level12.png -------------------------------------------------------------------------------- /levels/level13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level13.png -------------------------------------------------------------------------------- /levels/level14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level14.png -------------------------------------------------------------------------------- /levels/level15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level15.png -------------------------------------------------------------------------------- /levels/level16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level16.png -------------------------------------------------------------------------------- /levels/level17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level17.png -------------------------------------------------------------------------------- /levels/level18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level18.png -------------------------------------------------------------------------------- /levels/level19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level19.png -------------------------------------------------------------------------------- /levels/level20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level20.png -------------------------------------------------------------------------------- /levels/level21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level21.png -------------------------------------------------------------------------------- /levels/level22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level22.png -------------------------------------------------------------------------------- /levels/level23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level23.png -------------------------------------------------------------------------------- /levels/level24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level24.png -------------------------------------------------------------------------------- /levels/level25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level25.png -------------------------------------------------------------------------------- /levels/level26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level26.png -------------------------------------------------------------------------------- /levels/level27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level27.png -------------------------------------------------------------------------------- /levels/level28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level28.png -------------------------------------------------------------------------------- /levels/level29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level29.png -------------------------------------------------------------------------------- /levels/level30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level30.png -------------------------------------------------------------------------------- /levels/level31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level31.png -------------------------------------------------------------------------------- /levels/level32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level32.png -------------------------------------------------------------------------------- /levels/level33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level33.png -------------------------------------------------------------------------------- /levels/level34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level34.png -------------------------------------------------------------------------------- /levels/level35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level35.png -------------------------------------------------------------------------------- /levels/level36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level36.png -------------------------------------------------------------------------------- /levels/level37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level37.png -------------------------------------------------------------------------------- /levels/level38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level38.png -------------------------------------------------------------------------------- /levels/level39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level39.png -------------------------------------------------------------------------------- /levels/level40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/levels/level40.png -------------------------------------------------------------------------------- /sound/explosion.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/explosion.ogg -------------------------------------------------------------------------------- /graphics/overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/overlay.png -------------------------------------------------------------------------------- /screenshots/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/screenshots/banner.png -------------------------------------------------------------------------------- /screenshots/levels.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/screenshots/levels.jpg -------------------------------------------------------------------------------- /sound/accomplished.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/accomplished.ogg -------------------------------------------------------------------------------- /sound/bullet_start.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/bullet_start.ogg -------------------------------------------------------------------------------- /sound/deflection.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflection.ogg -------------------------------------------------------------------------------- /sound/deflector_up.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflector_up.ogg -------------------------------------------------------------------------------- /sound/deflectouch.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflectouch.ogg -------------------------------------------------------------------------------- /sound/no_deflector.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/no_deflector.ogg -------------------------------------------------------------------------------- /graphics/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/background.jpg -------------------------------------------------------------------------------- /graphics/button_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/button_down.png -------------------------------------------------------------------------------- /graphics/help_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/help_screen.png -------------------------------------------------------------------------------- /graphics/tank_tower.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/tank_tower.png -------------------------------------------------------------------------------- /screenshots/gameplay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/screenshots/gameplay.jpg -------------------------------------------------------------------------------- /screenshots/settings.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/screenshots/settings.jpg -------------------------------------------------------------------------------- /sound/deflector_down.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflector_down.ogg -------------------------------------------------------------------------------- /sound/deflector_new.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflector_new.ogg -------------------------------------------------------------------------------- /graphics/accomplished.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/accomplished.png -------------------------------------------------------------------------------- /graphics/button_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/button_normal.png -------------------------------------------------------------------------------- /graphics/deflector_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/deflector_blue.png -------------------------------------------------------------------------------- /graphics/deflector_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/deflector_red.png -------------------------------------------------------------------------------- /sound/deflector_delete.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/sound/deflector_delete.ogg -------------------------------------------------------------------------------- /graphics/finger_point_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/finger_point_white.png -------------------------------------------------------------------------------- /graphics/stockbar_limiter_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/stockbar_limiter_l.png -------------------------------------------------------------------------------- /graphics/stockbar_limiter_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stocyr/Deflectouch/HEAD/graphics/stockbar_limiter_r.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Deflectouch 2 | ============== 3 | 4 | ![banner](screenshots/banner.png) 5 | 6 | **[Youtube video](http://www.youtube.com/watch?v=1Qa98oSPgi0)** 7 | 8 | ![game play](screenshots/gameplay.jpg) 9 | ![help screen](graphics/help_screen.png) 10 | ![levels](screenshots/levels.jpg) 11 | ![settings](screenshots/settings.jpg) 12 | 13 | **[Thread on NUI-group](http://nuigroup.com/forums/viewthread/13600/)** 14 | 15 | READ THIS FIRST 16 | --------------- 17 | 18 | This application runs on the open source multitouch framework . 19 | For informations on the Kivy framework, please refer to http://kivy.org 20 | 21 | To install Kivy on your computer, see the Kivy documentation at 22 | http://kivy.org/docs/installation/installation.html 23 | 24 | ...or, for windows, read the section "Getting Started under Windows" which is a 25 | heavily summarized version of the above one. 26 | 27 | 28 | Copyright and Contact 29 | --------------------- 30 | 31 | Deflectouch Copyright (C) 2012 2015 Cyril Stoller 32 | 33 | This program comes with ABSOLUTELY NO WARRANTY. This is free software, 34 | and you are welcome to redistribute it under certain conditions; 35 | see the source code for details. 36 | 37 | For comments, suggestions or other messages contact me at: 38 | cyril.stoller@gmail.com 39 | 40 | 41 | Credits 42 | ------- 43 | 44 | * Sound: 45 | * beep.ogg, reset.ogg, select.ogg and switch.ogg are from the game *GUNSHIP!* from Microprose 46 | * All other sound files are created by myself 47 | * Music: 48 | * The deflectouch.ogg song is created by myself 49 | * Images: 50 | * www.gestureworks.com 51 | 52 | 53 | Release Notes 54 | ------------- 55 | 56 | Release history: 57 | 58 | * **V1.1**: *bug fixes, preparations for release on Google Play Store* 59 | * **V1.0**: *first released version* 60 | 61 | -------------------------------------------------------------------------------- /stockbar.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | import kivy 26 | kivy.require('1.0.9') 27 | 28 | from kivy.uix.image import Image 29 | from kivy.properties import NumericProperty 30 | 31 | MIN_DEFLECTOR_LENGTH = 100 32 | 33 | 34 | ''' 35 | #################################### 36 | ## 37 | ## Stock Bar Image Class 38 | ## 39 | #################################### 40 | ''' 41 | class Stockbar(Image): 42 | max_stock = NumericProperty(0) 43 | 44 | new_deflectors_allowed = True 45 | 46 | 47 | def recalculate_stock(self): 48 | # this function is called every time a deflector size is changing 49 | # first sum up all the deflectors on screen 50 | length_sum = 0 51 | 52 | if not len(self.parent.deflector_list) == 0: 53 | for deflector in self.parent.deflector_list: 54 | length_sum += deflector.length 55 | 56 | self.width = self.max_stock - length_sum 57 | 58 | if self.width < MIN_DEFLECTOR_LENGTH: 59 | # if the stock material doesn't suffice for a new deflector, disable new deflectors 60 | self.source = 'graphics/deflector_red.png' 61 | self.new_deflectors_allowed = False 62 | elif self.width <= 0: 63 | # if all the stock material was used up, disable new deflectors 64 | self.new_deflectors_allowed = False 65 | else: 66 | self.source = 'graphics/deflector_blue.png' 67 | self.new_deflectors_allowed = True 68 | 69 | def new_deflector(self, length): 70 | # is called when a new deflector is created. 71 | self.width -= length 72 | 73 | def deflector_deleted(self, length): 74 | self.width += length 75 | 76 | 77 | -------------------------------------------------------------------------------- /tank.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | 26 | import kivy 27 | kivy.require('1.0.9') 28 | 29 | from kivy.properties import ObjectProperty 30 | from kivy.graphics.transformation import Matrix 31 | from kivy.uix.widget import Widget 32 | 33 | from kivy.utils import boundary 34 | from math import radians 35 | from math import atan2 36 | from math import pi 37 | 38 | ''' 39 | #################################### 40 | ## 41 | ## Tank Class 42 | ## 43 | #################################### 44 | ''' 45 | class Tank(Widget): 46 | tank_tower_scatter = ObjectProperty(None) 47 | 48 | ''' 49 | #################################### 50 | ## 51 | ## On Touch Down 52 | ## 53 | #################################### 54 | ''' 55 | def on_touch_down(self, touch): 56 | if not self.collide_point(*touch.pos): 57 | return False 58 | else: 59 | touch.ud['tank_touch'] = True 60 | return True 61 | 62 | 63 | 64 | ''' 65 | #################################### 66 | ## 67 | ## On Touch Move 68 | ## 69 | #################################### 70 | ''' 71 | def on_touch_move(self, touch): 72 | ud = touch.ud 73 | 74 | if not 'tank_touch' in ud: 75 | return False 76 | 77 | if 'rotation_mode' in ud: 78 | # if the current touch is already in the 'rotate' mode, rotate the tower. 79 | dx = touch.x - self.center_x 80 | dy = touch.y - self.center_y 81 | angle = boundary(atan2(dy, dx) * 360 / 2 / pi, -60, 60) 82 | 83 | angle_change = self.tank_tower_scatter.rotation - angle 84 | rotation_matrix = Matrix().rotate(-radians(angle_change), 0, 0, 1) 85 | self.tank_tower_scatter.apply_transform(rotation_matrix, post_multiply=True, anchor=(105, 15)) 86 | 87 | elif touch.x > self.right: 88 | # if the finger moved too far to the right go into rotation mode 89 | ud['rotation_mode'] = True 90 | 91 | else: 92 | # if the user wants only to drag the tank up and down, let him do it! 93 | self.y += touch.dy 94 | pass 95 | 96 | -------------------------------------------------------------------------------- /background.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012-2024 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | import kivy 26 | kivy.require('1.0.9') 27 | 28 | from kivy.uix.image import Image 29 | from kivy.base import EventLoop 30 | from kivy.vector import Vector 31 | 32 | from deflector import Deflector 33 | 34 | 35 | MIN_DEFLECTOR_LENGTH = 100 36 | 37 | 38 | ''' 39 | #################################### 40 | ## 41 | ## Background Image Class 42 | ## 43 | #################################### 44 | ''' 45 | class Background(Image): 46 | 47 | ''' 48 | #################################### 49 | ## 50 | ## On Touch Down 51 | ## 52 | #################################### 53 | ''' 54 | def on_touch_down(self, touch): 55 | ud = touch.ud 56 | 57 | # if a bullet has been fired and is flying now, don't allow ANY change! 58 | if self.parent.bullet != None: 59 | return True 60 | 61 | for deflector in self.parent.deflector_list: 62 | if deflector.collide_grab_point(*touch.pos): 63 | # pass the touch to the deflector scatter 64 | return super(Background, self).on_touch_down(touch) 65 | 66 | # if i didn't wanted to move / scale a deflector and but rather create a new one: 67 | # search for other 'lonely' touches 68 | 69 | for search_touch in EventLoop.touches[:]: 70 | if 'lonely' in search_touch.ud: 71 | del search_touch.ud['lonely'] 72 | # so here we have a second touch: try to create a deflector: 73 | if self.parent.stockbar.new_deflectors_allowed == True: 74 | length = Vector(search_touch.pos).distance(touch.pos) 75 | # create only a new one if he's not too big and not too small 76 | if MIN_DEFLECTOR_LENGTH <= length <= self.parent.stockbar.width: 77 | self.create_deflector(search_touch, touch, length) 78 | else: 79 | self.parent.app.sound['no_deflector'].play() 80 | else: 81 | self.parent.app.sound['no_deflector'].play() 82 | 83 | return True 84 | 85 | # if no second touch was found: tag the current one as a 'lonely' touch 86 | ud['lonely'] = True 87 | 88 | 89 | def create_deflector(self, touch_1, touch_2, length): 90 | self.parent.app.sound['deflector_new'].play() 91 | deflector = Deflector(touch1=touch_1, touch2=touch_2, length=length) 92 | self.parent.deflector_list.append(deflector) 93 | self.add_widget(deflector) 94 | 95 | self.parent.stockbar.new_deflector(length) 96 | 97 | 98 | def delete_deflector(self, deflector): 99 | self.parent.app.sound['deflector_delete'].play() 100 | self.parent.stockbar.deflector_deleted(deflector.length) 101 | 102 | self.remove_widget(deflector) 103 | self.parent.deflector_list.remove(deflector) 104 | 105 | def delete_all_deflectors(self): 106 | for deflector in self.parent.deflector_list: 107 | self.remove_widget(deflector) 108 | self.parent.deflector_list = [] 109 | 110 | if self.parent.stockbar is not None: 111 | self.parent.stockbar.recalculate_stock() 112 | -------------------------------------------------------------------------------- /deflectouch.kv: -------------------------------------------------------------------------------- 1 | # 2 | # IcarusTouch 3 | # 4 | # Copyright (C) 2012-2024 Cyril Stoller 5 | # 6 | # For comments, suggestions or other messages, contact me at: 7 | # 8 | # 9 | # This file is part of Deflectouch. 10 | # 11 | # Deflectouch is free software: you can redistribute it and/or modify 12 | # it under the terms of the GNU General Public License as published by 13 | # the Free Software Foundation, either version 3 of the License, or 14 | # (at your option) any later version. 15 | # 16 | # Deflectouch is distributed in the hope that it will be fun, 17 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | # GNU General Public License for more details. 20 | # 21 | # You should have received a copy of the GNU General Public License 22 | # along with Deflectouch. If not, see . 23 | # 24 | 25 | 26 | #:kivy 1.0 27 | #:import kivy kivy 28 | #:import win kivy.core.window 29 | 30 | # Background description: 31 | : 32 | source: self.source 33 | allow_stretch: True 34 | keep_ratio: False 35 | size: app.window.size 36 | 37 | # Stock Bar description 38 | : 39 | source: 'graphics/deflector_blue.png' 40 | allow_stretch: True 41 | keep_ratio: False 42 | size_hint: None, None 43 | pos: self.pos 44 | size: self.max_stock, 20 45 | 46 | Image: 47 | source: 'graphics/stockbar_limiter_l.png' 48 | size_hint: None, None 49 | size: 51, 51 50 | y: root.center_y - self.height/2 51 | right: root.x 52 | 53 | Image: 54 | source: 'graphics/stockbar_limiter_r.png' 55 | size_hint: None, None 56 | size: 51, 51 57 | y: root.center_y - self.height/2 58 | x: root.x + root.max_stock 59 | 60 | # Tank description: 61 | : 62 | tank_tower_scatter: tank_tower_scatter 63 | tank_image_source: root.tank_image_source 64 | tower_image_source: root.tower_image_source 65 | # I want the tank image to be the bounding box: 66 | #size: tank_image.size 67 | size: 96, 140 68 | 69 | Image: 70 | id: 'tank_image' 71 | source: root.tank_image_source 72 | size: 96, 140 73 | pos: root.pos 74 | 75 | Scatter: 76 | id: tank_tower_scatter 77 | size_hint: None, None 78 | size: 210, 30 79 | center: root.center 80 | do_rotation: False 81 | do_scale: False 82 | do_translation: False 83 | 84 | Image: 85 | source: root.tower_image_source 86 | size: 210, 30 87 | pos: self.pos 88 | 89 | 90 | # Deflector description: 91 | : 92 | point1: point1 93 | point2: point2 94 | pos: self.pos 95 | 96 | Image: 97 | id: point1 98 | size: 40/root.scale, 40/root.scale 99 | pos: self.pos 100 | source: 'graphics/finger_point_white.png' 101 | color: 0, 0, 1, 1 102 | allow_stretch: True 103 | 104 | Image: 105 | id: point2 106 | size: 40/root.scale, 40/root.scale 107 | pos: self.pos 108 | source: 'graphics/finger_point_white.png' 109 | color: 0, 0, 1, 1 110 | allow_stretch: True 111 | 112 | # Image: 113 | # id: deflector_line 114 | # allow_stretch: True 115 | # keep_ratio: False 116 | # 117 | # canvas: 118 | # BorderImage: 119 | # source: 'graphics/beta/deflector_blue_beta.png' 120 | # border: 10, 10, 10, 10 121 | # size: self.width+10*2, self.height+10*2 122 | # pos: self.x-10, self.y-10 123 | 124 | 125 | # Bullet description: 126 | : 127 | source: 'graphics/bullet.png' 128 | size: 35 / (1200.0 / app.window.height), 35 / (1200.0 / app.window.height) 129 | size_hint: None, None 130 | 131 | 132 | # Setting dialog description 133 | : 134 | music_slider: music_slider 135 | sound_slider: sound_slider 136 | speed_slider: speed_slider 137 | close_button: close_button 138 | 139 | orientation: 'vertical' 140 | padding: 10 141 | spacing: 10 142 | 143 | Label: 144 | text: 'Music Volume:' 145 | Slider: 146 | id: music_slider 147 | Widget: 148 | heigth: 5 149 | 150 | Label: 151 | text: 'Sound Volume:' 152 | Slider: 153 | id: sound_slider 154 | Widget: 155 | heigth: 5 156 | 157 | Label: 158 | text: 'Bullet Speed:' 159 | Slider: 160 | id: speed_slider 161 | range: 1, 10 162 | Widget: 163 | heigth: 10 164 | 165 | BoxLayout: 166 | spacing: 10 167 | 168 | Button: 169 | text: 'Help' 170 | bold: True 171 | background_normal: 'graphics/button_normal.png' 172 | background_down: 'graphics/button_down.png' 173 | font_size: 15 174 | size_hint: 1, 1.5 175 | on_release: root.display_help_screen() 176 | 177 | Button: 178 | id: close_button 179 | text: 'Close' 180 | bold: True 181 | background_normal: 'graphics/button_normal.png' 182 | background_down: 'graphics/button_down.png' 183 | font_size: 15 184 | size_hint: 1, 1.5 185 | on_press: root.dismiss_parent() 186 | 187 | 188 | # Main widget description: 189 | : 190 | tank: tank 191 | background: background 192 | 193 | pos: self.pos 194 | size: app.window.size 195 | 196 | Background: 197 | id: background 198 | source: 'graphics/background.jpg' 199 | 200 | Image: 201 | source: 'graphics/overlay.png' 202 | allow_stretch: True 203 | keep_ratio: False 204 | size: app.window.size 205 | 206 | Image: 207 | source: 'graphics/rails.png' 208 | center_x: app.window.width/20 209 | size_hint: None, None 210 | height: app.window.height 211 | 212 | Tank: 213 | id: tank 214 | tank_image_source: 'graphics/tank.png' 215 | tower_image_source: 'graphics/tank_tower.png' 216 | center: app.window.width/20, app.window.center[1] 217 | 218 | BoxLayout: 219 | orientation: 'vertical' 220 | spacing: 15 221 | padding: 20 222 | 223 | size: app.window.width/8, app.window.height/2.0 224 | right: app.window.width 225 | top: app.window.height 226 | 227 | Button: 228 | text: 'Fire' 229 | bold: True 230 | font_size: 17 231 | background_normal: 'graphics/button_normal.png' 232 | background_down: 'graphics/button_down.png' 233 | on_press: root.fire_button_pressed() 234 | 235 | Button: 236 | text: 'Reset' 237 | bold: True 238 | font_size: 17 239 | background_normal: 'graphics/button_normal.png' 240 | background_down: 'graphics/button_down.png' 241 | on_press: root.reset_button_pressed() 242 | 243 | Label: 244 | text: 'Lives: ' + str(root.lives) 245 | bold: True 246 | font_size: 18 247 | size_hint: 1, 0.5 248 | color: 1, 1, 1, 1 249 | 250 | Button: 251 | text: 'Level ' + str(root.level) 252 | bold: True 253 | font_size: 17 254 | background_normal: 'graphics/button_normal.png' 255 | background_down: 'graphics/button_down.png' 256 | on_press: root.level_button_pressed() 257 | 258 | Widget: 259 | size_hint: 1, 0.5 260 | 261 | Button: 262 | text: 'Settings' 263 | bold: True 264 | font_size: 15 265 | background_normal: 'graphics/button_normal.png' 266 | background_down: 'graphics/button_down.png' 267 | on_press: root.settings_button_pressed() 268 | 269 | Button: 270 | text: 'Exit' 271 | bold: True 272 | font_size: 17 273 | background_normal: 'graphics/button_normal.png' 274 | background_down: 'graphics/button_down.png' 275 | on_press: root.app.stop() 276 | 277 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /deflector.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012-2024 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | 26 | import kivy 27 | kivy.require('1.0.9') 28 | 29 | from kivy.graphics import Line, Color 30 | from kivy.properties import ObjectProperty, NumericProperty 31 | from kivy.uix.scatter import Scatter 32 | 33 | from kivy.graphics.transformation import Matrix 34 | from math import atan2 35 | 36 | 37 | MIN_DEFLECTOR_LENGTH = 100 38 | GRAB_RADIUS = 30 39 | 40 | 41 | 42 | class Deflector(Scatter): 43 | touch1 = ObjectProperty(None) 44 | touch2 = ObjectProperty(None) 45 | 46 | point1 = ObjectProperty(None) 47 | point2 = ObjectProperty(None) 48 | 49 | deflector_line = ObjectProperty(None) 50 | 51 | length = NumericProperty(0) 52 | length_origin = 0 53 | 54 | point_pos_origin = [] 55 | 56 | ''' 57 | #################################### 58 | ## 59 | ## Class Initialisation 60 | ## 61 | #################################### 62 | ''' 63 | def __init__(self, **kwargs): 64 | super(Deflector, self).__init__(**kwargs) 65 | 66 | # DEFLECTOR LINE: 67 | # Here I rotate and translate the deflector line so that it lays exactly under the two fingers 68 | # and can be moved and scaled by scatter from now on. Thus I also have to pass the touches to scatter. 69 | # First i create the line perfectly horizontal but with the correct length. Then i add the two 70 | # drag points at the beginning and the end. 71 | 72 | self.length_origin = self.length 73 | 74 | with self.canvas.before: 75 | Color(.8, .8, .8) 76 | self.deflector_line = Line(points=(self.touch1.x, self.touch1.y - 1, self.touch1.x + self.length, self.touch1.y - 1)) 77 | self.deflector_line2 = Line(points=(self.touch1.x, self.touch1.y + 1, self.touch1.x + self.length, self.touch1.y + 1)) 78 | 79 | ''' 80 | self.deflector_line = Image(source='graphics/beta/deflector_blue_beta2.png', 81 | allow_stretch=True, 82 | keep_ratio=False, 83 | size=(self.length, 20), 84 | center_y=(self.touch1.y), 85 | x=self.touch1.x) 86 | ''' 87 | 88 | # set the right position for the two points: 89 | self.point1.center = self.touch1.pos 90 | self.point2.center = self.touch1.x + self.length, self.touch1.y 91 | self.point_pos_origin = [self.point1.x, self.point1.y, self.point2.x, self.point2.y] 92 | 93 | 94 | # rotation: 95 | dx = self.touch2.x - self.touch1.x 96 | dy = self.touch2.y - self.touch1.y 97 | angle = atan2(dy, dx) 98 | 99 | rotation_matrix = Matrix().rotate(angle, 0, 0, 1) 100 | self.apply_transform(rotation_matrix, post_multiply=True, anchor=self.to_local(self.touch1.x, self.touch1.y)) 101 | 102 | # We have to adjust the bounding box of ourself to the dimension of all the canvas objects (Do we have to?) 103 | #self.size = (abs(self.touch2.x - self.touch1.x), abs(self.touch2.y - self.touch1.y)) 104 | #self.pos = (min(self.touch1.x, self.touch2.x), min(self.touch1.y, self.touch2.y)) 105 | 106 | # Now we finally add both touches we received to the _touches list of the underlying scatter class structure. 107 | self.touch1.grab(self) 108 | self._touches.append(self.touch1) 109 | self._last_touch_pos[self.touch1] = self.touch1.pos 110 | 111 | self.touch2.grab(self) 112 | self._touches.append(self.touch2) 113 | self._last_touch_pos[self.touch2] = self.touch2.pos 114 | 115 | self.point1.bind(size=self.size_callback) 116 | 117 | def size_callback(self, instance, size): 118 | # problem: if the points are resized (scatter resized them, kv-rule resized them back), 119 | # their center isn't on the touch point anymore. 120 | self.point1.pos = self.point_pos_origin[0] + (40 - size[0])/2, self.point_pos_origin[1] + (40 - size[0])/2 121 | self.point2.pos = self.point_pos_origin[2] + (40 - size[0])/2, self.point_pos_origin[3] + (40 - size[0])/2 122 | 123 | # feedback to the stockbar: reducing of the deflector material stock: 124 | #self.length = Vector(self.touch1.pos).distance(self.touch2.pos) 125 | self.length = self.length_origin * self.scale 126 | try: 127 | self.parent.parent.stockbar.recalculate_stock() 128 | except Exception as e: 129 | return 130 | # get the current stock from the root widget: 131 | current_stock = self.parent.parent.stockbar.width 132 | stock_for_me = current_stock + self.length 133 | 134 | # now set the limitation for scaling: 135 | self.scale_max = stock_for_me / self.length_origin 136 | 137 | if self.length < MIN_DEFLECTOR_LENGTH: 138 | self.point1.color = (1, 0, 0, 1) 139 | self.point2.color = (1, 0, 0, 1) 140 | else: 141 | self.point1.color = (0, 0, 1, 1) 142 | self.point2.color = (0, 0, 1, 1) 143 | 144 | 145 | 146 | def collide_widget(self, wid): 147 | point1_parent = self.to_parent(self.point1.center[0], self.point1.center[1]) 148 | point2_parent = self.to_parent(self.point2.center[0], self.point2.center[1]) 149 | 150 | if max(point1_parent[0], point2_parent[0]) < wid.x: 151 | return False 152 | if min(point1_parent[0], point2_parent[0]) > wid.right: 153 | return False 154 | if max(point1_parent[1], point2_parent[1]) < wid.y: 155 | return False 156 | if min(point1_parent[1], point2_parent[1]) > wid.top: 157 | return False 158 | return True 159 | 160 | def collide_point(self, x, y): 161 | # this function is used exclusively by the underlying scatter functionality. 162 | # therefor i can control when a touch will be dispatched from here. 163 | point1_parent = self.to_parent(self.point1.center[0], self.point1.center[1]) 164 | point2_parent = self.to_parent(self.point2.center[0], self.point2.center[1]) 165 | 166 | return min(point1_parent[0], point2_parent[0]) - GRAB_RADIUS <= x <= max(point1_parent[0], point2_parent[0]) + GRAB_RADIUS \ 167 | and min(point1_parent[1], point2_parent[1]) - GRAB_RADIUS <= y <= max(point1_parent[1], point2_parent[1]) + GRAB_RADIUS 168 | 169 | def collide_grab_point(self, x, y): 170 | point1_parent = self.to_parent(self.point1.center[0], self.point1.center[1]) 171 | point2_parent = self.to_parent(self.point2.center[0], self.point2.center[1]) 172 | 173 | return point1_parent[0] - GRAB_RADIUS <= x <= point1_parent[0] + GRAB_RADIUS and point1_parent[1] - GRAB_RADIUS <= y <= point1_parent[1] + GRAB_RADIUS \ 174 | or point2_parent[0] - GRAB_RADIUS <= x <= point2_parent[0] + GRAB_RADIUS and point2_parent[1] - GRAB_RADIUS <= y <= point2_parent[1] + GRAB_RADIUS 175 | 176 | ''' 177 | #################################### 178 | ## 179 | ## On Touch Down 180 | ## 181 | #################################### 182 | ''' 183 | def on_touch_down(self, touch): 184 | if self.parent.parent.app.sound['deflector_down'].state != 'play': 185 | self.parent.parent.app.sound['deflector_down'].play() 186 | 187 | return super(Deflector, self).on_touch_down(touch) 188 | 189 | ''' 190 | #################################### 191 | ## 192 | ## On Touch Up 193 | ## 194 | #################################### 195 | ''' 196 | def on_touch_up(self, touch): 197 | # if the deflector want's to be removed (touches too close to each other): 198 | if self.length < MIN_DEFLECTOR_LENGTH and self.parent != None: 199 | self.parent.delete_deflector(self) 200 | return True 201 | 202 | if self.parent != None and self.collide_grab_point(*touch.pos): 203 | if self.parent.parent.app.sound['deflector_up'].state != 'play': 204 | self.parent.parent.app.sound['deflector_up'].play() 205 | 206 | return super(Deflector, self).on_touch_up(touch) 207 | 208 | 209 | -------------------------------------------------------------------------------- /bullet.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012-2024 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | 26 | import kivy 27 | kivy.require('1.8.0') 28 | 29 | from kivy.properties import NumericProperty 30 | from kivy.uix.image import Image 31 | from kivy.animation import Animation 32 | from kivy.graphics import Color, Point 33 | 34 | from kivy.utils import boundary 35 | from math import tan 36 | from math import sin 37 | from math import pi 38 | from math import radians 39 | from kivy.vector import Vector 40 | 41 | 42 | class Bullet(Image): 43 | angle = NumericProperty(0) # in radians! 44 | animation = None 45 | 46 | exploding = False 47 | 48 | ''' 49 | #################################### 50 | ## 51 | ## Bullet Behavioral 52 | ## 53 | #################################### 54 | ''' 55 | 56 | def __init__(self, **kwargs): 57 | super(Bullet, self).__init__(**kwargs) 58 | 59 | def fire(self): 60 | destination = self.calc_destination(self.angle) 61 | speed = boundary(self.parent.app.config.getint('GamePlay', 'BulletSpeed'), 1, 10) 62 | self.animation = self.create_animation(speed, destination) 63 | 64 | # start the animation 65 | self.animation.start(self) 66 | self.animation.bind(on_complete=self.on_collision_with_edge) 67 | 68 | # start to track the position changes 69 | self.bind(pos=self.callback_pos) 70 | 71 | def create_animation(self, speed, destination): 72 | # create the animation 73 | # t = s/v -> v from 1 to 10 / unit-less 74 | # NOTE: THE DIFFERENCE BETWEEN TWO RENDERED ANIMATION STEPS 75 | # MUST *NOT* EXCESS THE RADIUS OF THE BULLET! OTHERWISE I 76 | # HAVE PROBLEMS DETECTING A COLLISION WITH A DEFLECTOR!! 77 | time = Vector(self.center).distance(destination) / (speed * +70.0) 78 | # the splitting of the position animation in (x,y) is a work-around for the kivy issue #2667 for version < 1.9.0 79 | return Animation(x=destination[0],y=destination[1], duration=time, transition='linear') 80 | 81 | def calc_destination(self, angle): 82 | # calculate the path until the bullet hits the edge of the screen 83 | win = self.get_parent_window() 84 | # the following "magic numbers" are based on the dimensions of the 85 | # cutting of the image 'overlay.png' 86 | left = 150.0 * win.width / 1920.0 87 | right = win.width - 236.0 * win.width / 1920.0 88 | top = win.height - 50.0 * win.height / 1920.0 89 | bottom = 96.0 * win.height / 1920.0 90 | 91 | bullet_x_to_right = right - self.center_x 92 | bullet_x_to_left = left - self.center_x 93 | bullet_y_to_top = top - self.center_y 94 | bullet_y_to_bottom = bottom - self.center_y 95 | 96 | destination_x = 0 97 | destination_y = 0 98 | 99 | 100 | # this is a little bit ugly, but I couldn't find a nicer way in the hurry 101 | if 0 <= self.angle < pi/2: 102 | # 1st quadrant 103 | if self.angle == 0: 104 | destination_x = bullet_x_to_right 105 | destination_y = 0 106 | else: 107 | destination_x = boundary(bullet_y_to_top / tan(self.angle), bullet_x_to_left, bullet_x_to_right) 108 | destination_y = boundary(tan(self.angle) * bullet_x_to_right, bullet_y_to_bottom, bullet_y_to_top) 109 | 110 | elif pi/2 <= self.angle < pi: 111 | # 2nd quadrant 112 | if self.angle == pi/2: 113 | destination_x = 0 114 | destination_y = bullet_y_to_top 115 | else: 116 | destination_x = boundary(bullet_y_to_top / tan(self.angle), bullet_x_to_left, bullet_x_to_right) 117 | destination_y = boundary(tan(self.angle) * bullet_x_to_left, bullet_y_to_bottom, bullet_y_to_top) 118 | 119 | elif pi <= self.angle < 3*pi/2: 120 | # 3rd quadrant 121 | if self.angle == pi: 122 | destination_x = bullet_x_to_left 123 | destination_y = 0 124 | else: 125 | destination_x = boundary(bullet_y_to_bottom / tan(self.angle), bullet_x_to_left, bullet_x_to_right) 126 | destination_y = boundary(tan(self.angle) * bullet_x_to_left, bullet_y_to_bottom, bullet_y_to_top) 127 | 128 | elif self.angle >= 3*pi/2: 129 | # 4th quadrant 130 | if self.angle == 3*pi/2: 131 | destination_x = 0 132 | destination_y = bullet_y_to_bottom 133 | else: 134 | destination_x = boundary(bullet_y_to_bottom / tan(self.angle), bullet_x_to_left, bullet_x_to_right) 135 | destination_y = boundary(tan(self.angle) * bullet_x_to_right, bullet_y_to_bottom, bullet_y_to_top) 136 | 137 | 138 | # because all of the calculations above were relative, add the bullet position to it. 139 | destination_x += self.center_x 140 | destination_y += self.center_y 141 | 142 | return (destination_x, destination_y) 143 | 144 | def check_deflector_collision(self, deflector): 145 | # Here we have a collision Bullet <--> Deflector-bounding-box. But that doesn't mean 146 | # that there's a collision with the deflector LINE yet. So here's some math stuff 147 | # for the freaks :) It includes vector calculations, distance problems and trigonometry 148 | 149 | # first thing to do is: we need a vector describing the bullet. Length isn't important. 150 | bullet_position = Vector(self.center) 151 | bullet_direction = Vector(1, 0).rotate(self.angle * 360 / (2*pi)) 152 | deflector_point1 = Vector(deflector.to_parent(deflector.point1.center[0], deflector.point1.center[1])) 153 | deflector_point2 = Vector(deflector.to_parent(deflector.point2.center[0], deflector.point2.center[1])) 154 | 155 | # then we need a vector describing the deflector line. 156 | deflector_vector = Vector(deflector_point2 - deflector_point1) 157 | 158 | # now we do a line intersection with the deflector line: 159 | intersection = Vector.line_intersection(bullet_position, bullet_position + bullet_direction, deflector_point1, deflector_point2) 160 | 161 | # now we want to proof if the bullet comes from the 'right' side. 162 | # Because it's possible that the bullet is colliding with the deflectors bounding box but 163 | # would miss / has already missed the deflector line. 164 | # We do that by checking if the expected intersection point is BEHIND the bullet position. 165 | # ('behind' means the bullets direction vector points AWAY from the vector 166 | # [bullet -> intersection]. That also means the angle between these two vectors is not 0 167 | # -> due to some math-engine-internal inaccuracies, i have to check if the angle is greater than one: 168 | if abs(bullet_direction.angle(intersection - bullet_position)) > 1: 169 | # if the bullet missed the line already - NO COLLISION 170 | return False 171 | 172 | # now we finally check if the bullet is close enough to the deflector line: 173 | distance = abs(sin(radians(bullet_direction.angle(deflector_vector)) % (pi/2))) * Vector(intersection - bullet_position).length() 174 | if distance < (self.width / 2): 175 | # there is a collision! 176 | # kill the animation! 177 | self.animation.unbind(on_complete=self.on_collision_with_edge) 178 | self.animation.stop(self) 179 | # call the collision handler 180 | self.on_collision_with_deflector(deflector, deflector_vector) 181 | 182 | 183 | 184 | def callback_pos(self, instance, pos): 185 | # check here if the bullet collides with a deflector, an obstacle or the goal 186 | # (edge collision detection is irrelevant - the edge is where the bullet animation ends 187 | # and therefor a callback is raised then) 188 | 189 | # first check if there's a collision with deflectors: 190 | if not len(self.parent.deflector_list) == 0: 191 | for deflector in self.parent.deflector_list: 192 | if deflector.collide_widget(self): 193 | self.check_deflector_collision(deflector) 194 | return 195 | 196 | # then check if there's a collision with the goal: 197 | if not len(self.parent.goal_list) == 0: 198 | for goal in self.parent.goal_list: 199 | if self.collide_widget(goal): 200 | self.on_collision_with_goal() 201 | return 202 | 203 | # then check if there's a collision with obstacles: 204 | if not len(self.parent.obstacle_list) == 0: 205 | for obstacle in self.parent.obstacle_list: 206 | if self.collide_widget(obstacle): 207 | self.on_collision_with_obstacle() 208 | return 209 | 210 | def bullet_explode(self): 211 | if self.exploding == True: 212 | return 213 | self.exploding = True 214 | 215 | self.unbind(pos=self.callback_pos) 216 | self.animation.unbind(on_complete=self.on_collision_with_edge) 217 | self.animation.stop(self) 218 | 219 | self.parent.bullet_exploding() 220 | 221 | def on_collision_with_edge(self, animation, widget): 222 | self.bullet_explode() 223 | 224 | def on_collision_with_obstacle(self): 225 | self.bullet_explode() 226 | 227 | def on_collision_with_deflector(self, deflector, deflector_vector): 228 | self.parent.app.sound['deflection'].play() 229 | 230 | # flash up the deflector 231 | Animation.stop_all(deflector.point1, 'color') 232 | Animation.stop_all(deflector.point2, 'color') 233 | deflector.point1.color = (1, 1, 1, 1) 234 | deflector.point2.color = (1, 1, 1, 1) 235 | animation = Animation(color=(0, 0, 1, 1), duration=3, t='out_expo') 236 | animation.start(deflector.point1) 237 | animation.start(deflector.point2) 238 | 239 | # calculate deflection angle 240 | impact_angle = (radians(deflector_vector.angle(Vector(1, 0))) % pi) - (self.angle % pi) 241 | self.angle = (self.angle + 2*impact_angle) % (2*pi) 242 | 243 | destination = self.calc_destination(self.angle) 244 | speed = boundary(self.parent.app.config.getint('GamePlay', 'BulletSpeed'), 1, 10) 245 | self.animation = self.create_animation(speed, destination) 246 | 247 | # start the animation 248 | self.animation.start(self) 249 | self.animation.bind(on_complete=self.on_collision_with_edge) 250 | 251 | def on_collision_with_goal(self): 252 | # i still have some strange exceptions because of multiple function calls: 253 | if self.parent is None: 254 | return 255 | self.parent.level_accomplished() 256 | 257 | self.bullet_explode() 258 | 259 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Deflectouch 3 | 4 | Copyright (C) 2012-2024 Cyril Stoller 5 | 6 | For comments, suggestions or other messages, contact me at: 7 | 8 | 9 | This file is part of Deflectouch. 10 | 11 | Deflectouch is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | Deflectouch is distributed in the hope that it will be fun, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with Deflectouch. If not, see . 23 | ''' 24 | 25 | 26 | import kivy 27 | kivy.require('1.8.0') 28 | 29 | from kivy.app import App 30 | from kivy.properties import ObjectProperty, StringProperty, NumericProperty 31 | from kivy.factory import Factory 32 | from kivy.utils import boundary 33 | from kivy.clock import Clock 34 | from kivy.animation import Animation 35 | from kivy.core.audio import SoundLoader 36 | 37 | from kivy.uix.image import Image 38 | from kivy.uix.widget import Widget 39 | from kivy.uix.popup import Popup 40 | from kivy.uix.boxlayout import BoxLayout 41 | from kivy.uix.gridlayout import GridLayout 42 | from kivy.uix.button import Button 43 | from kivy.uix.label import Label 44 | 45 | from math import sin 46 | from math import cos 47 | from math import radians 48 | 49 | from random import randint 50 | 51 | 52 | from background import Background 53 | from tank import Tank 54 | from bullet import Bullet 55 | from stockbar import Stockbar 56 | 57 | 58 | ''' 59 | #################################### 60 | ## 61 | ## GLOBAL SETTINGS 62 | ## 63 | #################################### 64 | ''' 65 | 66 | VERSION = '1.1.2' 67 | 68 | LEVEL_WIDTH = 16 69 | LEVEL_HEIGHT = 16 70 | 71 | 72 | ''' 73 | #################################### 74 | ## 75 | ## Setting Dialog Class 76 | ## 77 | #################################### 78 | ''' 79 | class SettingDialog(BoxLayout): 80 | music_slider = ObjectProperty(None) 81 | sound_slider = ObjectProperty(None) 82 | speed_slider = ObjectProperty(None) 83 | 84 | root = ObjectProperty(None) 85 | 86 | def __init__(self, **kwargs): 87 | super(SettingDialog, self).__init__(**kwargs) 88 | 89 | self.music_slider.bind(value=self.update_music_volume) 90 | self.sound_slider.bind(value=self.update_sound_volume) 91 | self.speed_slider.bind(value=self.update_speed) 92 | 93 | def update_music_volume(self, instance, value): 94 | # write to app configs 95 | self.root.app.config.set('General', 'Music', str(int(value))) 96 | self.root.app.config.write() 97 | self.root.app.music.volume = value / 100.0 98 | 99 | def update_sound_volume(self, instance, value): 100 | # write to app configs 101 | self.root.app.config.set('General', 'Sound', str(int(value))) 102 | self.root.app.config.write() 103 | for item in self.root.app.sound: 104 | self.root.app.sound[item].volume = value / 100.0 105 | 106 | def update_speed(self, instance, value): 107 | # write to app configs 108 | self.root.app.config.set('GamePlay', 'BulletSpeed', str(int(value))) 109 | self.root.app.config.write() 110 | 111 | def display_help_screen(self): 112 | self.root.setting_popup.dismiss() 113 | self.root.display_help_screen() 114 | 115 | def dismiss_parent(self): 116 | self.root.setting_popup.dismiss() 117 | 118 | 119 | ''' 120 | #################################### 121 | ## 122 | ## Main Widget Class 123 | ## 124 | #################################### 125 | ''' 126 | class DeflectouchWidget(Widget): 127 | app = ObjectProperty(None) 128 | version = StringProperty(VERSION) 129 | 130 | level = NumericProperty(1) 131 | lives = NumericProperty(3) 132 | 133 | bullet = None 134 | setting_popup = None 135 | stockbar = None 136 | 137 | deflector_list = [] 138 | obstacle_list = [] 139 | goal_list = [] 140 | 141 | max_stock = 0 142 | 143 | level_build_index = 0 144 | 145 | 146 | ''' 147 | #################################### 148 | ## 149 | ## GUI Functions 150 | ## 151 | #################################### 152 | ''' 153 | def fire_button_pressed(self): 154 | if self.bullet: 155 | # if there is already a bullet existing (which means it's flying around or exploding somewhere) 156 | # don't fire. 157 | return 158 | 159 | self.app.sound['bullet_start'].play() 160 | 161 | # create a bullet, calculate the start position and fire it. 162 | tower_angle = radians(self.tank.tank_tower_scatter.rotation) 163 | tower_position = self.tank.pos 164 | bullet_position = (tower_position[0] + 48 + cos(tower_angle) * 130, tower_position[1] + 70 + sin(tower_angle) * 130) 165 | self.bullet = Bullet(angle=tower_angle) 166 | self.bullet.center = bullet_position 167 | self.add_widget(self.bullet) 168 | self.bullet.fire() 169 | 170 | 171 | def reset_button_pressed(self): 172 | self.app.sound['reset'].play() 173 | 174 | self.reset_level() 175 | 176 | 177 | def level_button_pressed(self): 178 | self.app.sound['switch'].play() 179 | 180 | # create a popup with all the levels 181 | grid_layout = GridLayout(cols=8,rows=5,spacing=10, padding=10) 182 | 183 | enable_next_row = True 184 | row_not_complete = False 185 | for row in range(5): 186 | for collumn in range(8): 187 | button = Button(text=str(row*8 + (collumn + 1)),bold=True,font_size=30) 188 | 189 | if enable_next_row == True: 190 | # if this row is already enabled: 191 | button.bind(on_press=self.load_level) 192 | 193 | if self.app.config.get('GamePlay', 'Levels')[row*8 + collumn] == '1': 194 | # if level was already done, green button 195 | button.background_color = (0, 1, 0, 1) 196 | else: 197 | # if level not yet done but enabled though, red button 198 | button.background_color = (1, 0, 0, 0.5) 199 | 200 | # and do NOT enable the next row then: 201 | row_not_complete = True 202 | 203 | else: 204 | # if not yet enabled: 205 | button.background_color = (0.1, 0.05, 0.05, 1) 206 | 207 | grid_layout.add_widget(button) 208 | 209 | if row_not_complete == True: 210 | enable_next_row = False 211 | 212 | popup = Popup(title='Level List (if you finished a row, the next row will get enabled!)', 213 | content=grid_layout, 214 | size_hint=(0.5, 0.5)) 215 | popup.open() 216 | 217 | 218 | def settings_button_pressed(self): 219 | self.app.sound['switch'].play() 220 | 221 | # the first time the setting dialog is called, initialize its content. 222 | if self.setting_popup is None: 223 | 224 | self.setting_popup = Popup(attach_to=self, 225 | title='DeflecTouch Settings', 226 | size_hint=(0.3, 0.5)) 227 | 228 | self.setting_dialog = SettingDialog(root=self) 229 | 230 | self.setting_popup.content = self.setting_dialog 231 | 232 | self.setting_dialog.music_slider.value = boundary(self.app.config.getint('General', 'Music'), 0, 100) 233 | self.setting_dialog.sound_slider.value = boundary(self.app.config.getint('General', 'Sound'), 0, 100) 234 | self.setting_dialog.speed_slider.value = boundary(self.app.config.getint('GamePlay', 'BulletSpeed'), 1, 10) 235 | 236 | self.setting_popup.open() 237 | 238 | 239 | def display_help_screen(self): 240 | # display the help screen on a Popup 241 | image = Image(source='graphics/help_screen.png') 242 | 243 | help_screen = Popup(title='Quick Guide through DEFLECTOUCH', 244 | attach_to=self, 245 | size_hint=(0.98, 0.98), 246 | content=image) 247 | image.bind(on_touch_down=help_screen.dismiss) 248 | help_screen.open() 249 | 250 | 251 | ''' 252 | #################################### 253 | ## 254 | ## Game Play Functions 255 | ## 256 | #################################### 257 | ''' 258 | 259 | def bullet_exploding(self): 260 | self.app.sound['explosion'].play() 261 | 262 | # create an animation on the old bullets position: 263 | # bug: gif isn't transparent 264 | #old_pos = self.bullet.center 265 | #self.bullet.anim_delay = 0.1 266 | #self.bullet.size = 96, 96 267 | #self.bullet.center = old_pos 268 | #self.bullet.source = 'graphics/explosion.gif' 269 | #Clock.schedule_once(self.bullet_exploded, 1) 270 | 271 | self.remove_widget(self.bullet) 272 | self.bullet = None 273 | # or should i write del self.bullet instead? 274 | 275 | self.lives -= 1 276 | if self.lives == 0: 277 | self.reset_level() 278 | 279 | 280 | def level_accomplished(self): 281 | self.app.sound['accomplished'].play() 282 | 283 | # store score in config: (i have to convert the string to a list to do specific char writing) 284 | levels_before = list(self.app.config.get('GamePlay', 'Levels')) 285 | levels_before[self.level - 1] = '1' 286 | self.app.config.set('GamePlay', 'Levels', "".join(levels_before)) 287 | self.app.config.write() 288 | 289 | # show up a little image with animation: size*2 and out_bounce and the wait 1 sec 290 | image = Image(source='graphics/accomplished.png', size_hint=(None, None), size=(200, 200)) 291 | image.center=self.center 292 | animation = Animation(size=(350, 416), duration=1, t='out_bounce') 293 | animation &= Animation(center=self.center, duration=1, t='out_bounce') 294 | animation += Animation(size=(350, 416), duration=1) # little hack to sleep for 1 sec 295 | 296 | self.add_widget(image) 297 | animation.start(image) 298 | animation.bind(on_complete=self.accomplished_animation_complete) 299 | 300 | 301 | def accomplished_animation_complete(self, animation, widget): 302 | self.remove_widget(widget) 303 | 304 | # open the level dialog? 305 | #self.level_button_pressed() 306 | 307 | # no. just open the next level. 308 | if self.level != 40: 309 | if self.level % 8 == 0: 310 | # if it was the last level of one row, another row has been unlocked! 311 | Popup(title='New levels unlocked!', content=Label(text='Next 8 levels unlocked!', font_size=18), size_hint=(0.3, 0.15)).open() 312 | 313 | self.reset_level() 314 | self.load_level(self.level + 1) 315 | 316 | 317 | def reset_level(self): 318 | # first kill the bullet 319 | if self.bullet != None: 320 | self.bullet.unbind(pos=self.bullet.callback_pos) 321 | self.bullet.animation.unbind(on_complete=self.bullet.on_collision_with_edge) 322 | self.bullet.animation.stop(self.bullet) 323 | self.remove_widget(self.bullet) 324 | self.bullet = None 325 | 326 | # then delete all the deflectors. 327 | self.background.delete_all_deflectors() 328 | 329 | # now the user can begin once again with 3 lives: 330 | self.lives = 3 331 | 332 | 333 | def load_level(self, level): 334 | BRICK_WIDTH = self.height / 17.73 335 | LEVEL_OFFSET = [self.center_x - (LEVEL_WIDTH/2) * BRICK_WIDTH, self.height / 12.5] 336 | 337 | # i have to check if the function is called by a level button in the level popup OR with an int as argument: 338 | if not isinstance(level, int): 339 | level = int(level.text) 340 | # and if the function was called by a button, play a sound 341 | self.app.sound['select'].play() 342 | 343 | # try to load the level image 344 | try: 345 | level_image = kivy.core.image.Image.load(self.app.directory + '/levels/level%02d.png' % level, keep_data=True) 346 | except Exception as e: 347 | error_text = 'Unable to load Level %d!\n\nReason: %s' % (level, e) 348 | Popup(title='Level loading error:', content=Label(text=error_text, font_size=18), size_hint=(0.3, 0.2)).open() 349 | return 350 | 351 | # First of all, delete the old level: 352 | self.reset_level() 353 | 354 | for obstacle in self.obstacle_list: 355 | self.background.remove_widget(obstacle) 356 | self.obstacle_list = [] 357 | 358 | for goal in self.goal_list: 359 | self.background.remove_widget(goal) 360 | self.goal_list = [] 361 | 362 | if self.stockbar != None: 363 | self.remove_widget(self.stockbar) 364 | self.max_stock = 0 365 | 366 | # set level initial state 367 | self.lives = 3 368 | self.level = level 369 | 370 | for y in range(LEVEL_HEIGHT): 371 | for x in range(LEVEL_WIDTH): 372 | color = level_image.read_pixel(x, y) 373 | if len(color) > 3: 374 | # if there was transparency stored in the image, cut it. 375 | color.pop() 376 | 377 | if color == [0, 0, 0]: 378 | # create obstacle brick on black pixels 379 | image = Image(source=('graphics/brick%d.png' % randint(1, 4)), 380 | x = LEVEL_OFFSET[0] + x * BRICK_WIDTH, 381 | y = LEVEL_OFFSET[1] + (LEVEL_HEIGHT-1-y) * BRICK_WIDTH, 382 | size = (BRICK_WIDTH, BRICK_WIDTH), 383 | allow_stretch = True) 384 | self.obstacle_list.append(image) 385 | # the actual widget adding is done in build_level() 386 | #self.background.add_widget(image) 387 | 388 | elif color == [0, 0, 1]: 389 | # create a goal brick on blue pixels 390 | image = Image(source=('graphics/goal%d.png' % randint(1, 4)), 391 | x = LEVEL_OFFSET[0] + x * BRICK_WIDTH, 392 | y = LEVEL_OFFSET[1] + (LEVEL_HEIGHT-1-y) * BRICK_WIDTH, 393 | size = (BRICK_WIDTH, BRICK_WIDTH), 394 | allow_stretch = True) 395 | self.goal_list.append(image) 396 | # the actual widget adding is done in build_level() 397 | #self.background.add_widget(image) 398 | 399 | 400 | # but in the lowermost row there is also stored the value for the maximum stock 401 | for x in range(LEVEL_WIDTH): 402 | color = level_image.read_pixel(x, LEVEL_HEIGHT) 403 | if len(color) > 3: 404 | # if there was transparency stored in the image, cut it. 405 | color.pop() 406 | 407 | # add max_stock for each red pixel 408 | if color == [1, 0, 0]: 409 | self.max_stock += 1 410 | 411 | # now set up the stockbar widget: 412 | self.max_stock = self.max_stock * self.width/1.4/LEVEL_WIDTH 413 | self.stockbar = Stockbar(max_stock=self.max_stock, 414 | x=self.center_x-self.max_stock/2, 415 | center_y=self.height/16 + 20) 416 | self.add_widget(self.stockbar) 417 | 418 | # now start to build up the level: 419 | self.level_build_index = 0 420 | if len(self.obstacle_list) != 0: 421 | Clock.schedule_interval(self.build_level, 0.01) 422 | 423 | 424 | def build_level(self, instance): 425 | #if self.level_build_index % int(0.02 / (0.5 / (len(self.obstacle_list) + len(self.goal_list)))) == 0: 426 | # play a sound every now and then: 427 | self.app.sound['beep'].play() 428 | 429 | if self.level_build_index < len(self.obstacle_list): 430 | self.background.add_widget(self.obstacle_list[self.level_build_index]) 431 | else: 432 | if self.level_build_index - len(self.obstacle_list) != len(self.goal_list): 433 | self.background.add_widget(self.goal_list[self.level_build_index - len(self.obstacle_list)]) 434 | else: 435 | # we're done. Disable the schedule 436 | return False 437 | self.level_build_index += 1 438 | 439 | Factory.register("Tank", Tank) 440 | Factory.register("Background", Background) 441 | Factory.register("Stockbar", Stockbar) 442 | 443 | 444 | ''' 445 | #################################### 446 | ## 447 | ## Main Application Class 448 | ## 449 | #################################### 450 | ''' 451 | class Deflectouch(App): 452 | title = 'Deflectouch' 453 | sound = {} 454 | music = None 455 | 456 | def build(self): 457 | self.icon = 'icon.png' 458 | # print the application informations 459 | print('\nDeflectouch v%s Copyright (C) 2012 2015 Cyril Stoller' % VERSION) 460 | print('This program comes with ABSOLUTELY NO WARRANTY') 461 | print('This is free software, and you are welcome to redistribute it') 462 | print('under certain conditions; see the source code for details.\n') 463 | 464 | from kivy.base import EventLoop 465 | EventLoop.ensure_window() 466 | self.window = EventLoop.window 467 | 468 | # create the root widget and give it a reference of the application instance (so it can access the application settings) 469 | self.deflectouchwidget = DeflectouchWidget(app=self) 470 | self.root = self.deflectouchwidget 471 | 472 | 473 | # start the background music: 474 | self.music = SoundLoader.load('sound/deflectouch.ogg') 475 | self.music.volume = self.config.getint('General', 'Music') / 100.0 476 | self.music.bind(on_stop=self.sound_replay) 477 | self.music.play() 478 | 479 | # load all other sounds: 480 | self.sound['switch'] = SoundLoader.load('sound/switch.ogg') 481 | self.sound['select'] = SoundLoader.load('sound/select.ogg') 482 | self.sound['reset'] = SoundLoader.load('sound/reset.ogg') 483 | self.sound['beep'] = SoundLoader.load('sound/beep.ogg') 484 | 485 | self.sound['bullet_start'] = SoundLoader.load('sound/bullet_start.ogg') 486 | self.sound['explosion'] = SoundLoader.load('sound/explosion.ogg') 487 | self.sound['accomplished'] = SoundLoader.load('sound/accomplished.ogg') 488 | 489 | self.sound['no_deflector'] = SoundLoader.load('sound/no_deflector.ogg') 490 | self.sound['deflector_new'] = SoundLoader.load('sound/deflector_new.ogg') 491 | self.sound['deflector_down'] = SoundLoader.load('sound/deflector_down.ogg') 492 | self.sound['deflector_up'] = SoundLoader.load('sound/deflector_up.ogg') 493 | self.sound['deflector_delete'] = SoundLoader.load('sound/deflector_delete.ogg') 494 | self.sound['deflection'] = SoundLoader.load('sound/deflection.ogg') 495 | 496 | sound_volume = self.config.getint('General', 'Sound') / 100.0 497 | for item in self.sound: 498 | self.sound[item].volume = sound_volume 499 | 500 | # continue on the last level which wasn't finished 501 | level_opened = False 502 | for counter, char in enumerate(self.config.get('GamePlay', 'Levels')): 503 | # if I found a level not yet done, continue with that 504 | if char == '0': 505 | self.deflectouchwidget.load_level(counter + 1) 506 | level_opened = True 507 | break 508 | 509 | # if all levels were completed, just open the last one. 510 | if level_opened == False: 511 | self.deflectouchwidget.load_level(40) 512 | 513 | # if the user started the game the first time, display quick start guide 514 | if self.config.get('General', 'FirstStartup') == 'Yes': 515 | 516 | Clock.schedule_once(self.welcome_screen, 2) 517 | 518 | self.config.set('General', 'FirstStartup', 'No') 519 | self.config.write() 520 | 521 | return self.root 522 | 523 | 524 | def build_config(self, config): 525 | config.adddefaultsection('General') 526 | config.setdefault('General', 'Music', '100') 527 | config.setdefault('General', 'Sound', '100') 528 | config.setdefault('General', 'FirstStartup', 'Yes') 529 | 530 | config.adddefaultsection('GamePlay') 531 | config.setdefault('GamePlay', 'BulletSpeed', '10') 532 | config.setdefault('GamePlay', 'Levels', '0000000000000000000000000000000000000000') 533 | 534 | def welcome_screen(self, instance): 535 | self.root.display_help_screen() 536 | 537 | def sound_replay(self, instance): 538 | if self.music.state != 'play': 539 | self.music.play() 540 | 541 | 542 | if __name__ in ('__main__', '__android__'): 543 | Deflectouch().run() 544 | 545 | -------------------------------------------------------------------------------- /gpl-3.0.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------