-
Notifications
You must be signed in to change notification settings - Fork 0
/
title.py
executable file
·137 lines (110 loc) · 4.36 KB
/
title.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# coding=UTF-8
'''
Created on 23 janv. 3016
@author: Sam Neurohack
'''
import gstt
import vectors
from globalVars import *
ZOOM_PLAYING = .5
ZOOM_GAMEOVER = 5.0
DZOOM_PLAYING = -.4
DZOOM_GAMEOVER = .1
# Finalement, on implémente le score ici
ASCII_GRAPHICS = [
#implementé
[[(-50,30), (-30,-30), (30,-30), (10,30), (-50,30)]], #0
[[(-20,30), (0,-30), (-20,30)]], #1
[[(-30,-10), (0,-30), (30,-10), (30,0), (-30,30), (30,30)]], #2
[[(-30,-30), (0,-30), (30,-10), (0,0), (30,10), (0,30), (-30,30)]], #3
[[(30,10), (-30,10), (0,-30), (0,30)]], #4
[[(30,-30), (-30,-30), (-30,0), (0,0), (30,10), (0,30), (-30,30)]], #5
[[(30,-30), (0,-30), (-30,-10), (-30,30), (0,30), (30,10), (30,0), (-30,0)]], #6
[[(-30,-30), (30,-30), (-30,30)]], #7
[[(-30,30), (-30,-30), (30,-30), (30,30), (-30,30), (-30,0), (30,0)]], #8
[[(30,0), (-30,0), (-30,-10), (0,-30), (30,-30), (30,10), (0,30), (-30,30)]], #9
# A implementer
[[(-30,10), (30,-10), (30,10), (0,30), (-30,10), (-30,-10), (0,-30), (30,-10)]], #:
[[(-30,-10), (0,-30), (0,30)], [(-30,30), (30,30)]], #;
[[(-30,-10), (0,-30), (30,-10), (30,0), (-30,30), (30,30)]], #<
[[(-30,-30), (0,-30), (30,-10), (0,0), (30,10), (0,30), (-30,30)]], #=
[[(30,10), (-30,10), (0,-30), (0,30)]], #>
[[(30,-30), (-30,-30), (-30,0), (0,0), (30,10), (0,30), (-30,30)]], #?
[[(30,-30), (0,-30), (-30,-10), (-30,30), (0,30), (30,10), (30,0), (-30,0)]], #@
# Implementé
[[(-30,30), (-30,-30), (30,-30), (30,30), (30,0), (-30,0)]], #A
[[(-30,30), (-30,-30), (30,-30), (30,30), (30,0), (-30,0)]], #A
[[(-30,30), (-30,-30), (30,-30), (30,30), (-30,30), (-30,0), (30,0)]], #B
[[(30,30), (-30,30), (-30,-30), (30,-30)]], #C
[[(-30,30), (-30,-30), (30,-30), (30,30), (-30,30)]], #D
[[(30,30), (-30,30), (-30,-0), (30,0), (-30,0), (-30,-30), (30,-30)]], #E
[[(-30,30), (-30,-0), (30,0), (-30,0), (-30,-30), (30,-30)]], #F
[[(0,0), (30,0), (30,30), (-30,30), (-30,-30),(30,-30)]], #G
[[(-30,-30), (-30,30), (-30,0), (30,0), (30,30), (30,-30)]], #H
[[(0,30), (0,-30)]], #I
[[(-30,30), (0,-30), (0,-30), (-30,-30), (30,-30)]], #J
[[(-30,-30), (-30,30), (-30,0), (30,-30), (-30,0), (30,30)]], #K
[[(30,30), (-30,30), (-30,-30)]], #L
[[(-30,30), (-30,-30), (0,0), (30,-30), (30,30)]], #M
[[(-30,30), (-30,-30), (30,30), (30,-30)]], #N
[[(-30,30), (-30,-30), (30,-30), (30,30), (-30,30)]], #O
[[(-30,0), (30,0), (30,-30), (-30,-30), (-30,30)]], #P
[[(30,30), (30,-30), (-30,-30), (-30,30), (30,30),(35,35)]], #Q
[[(-30,30), (-30,-30), (30,-30), (30,0), (-30,0), (30,30)]], #R
[[(30,-30), (-30,-30), (-30,0), (30,0), (30,30), (-30,30)]], #S
[[(0,30), (0,-30), (-30,-30), (30,-30)]], #T
[[(-30,-30), (-30,30), (30,30), (30,-30)]], #U
[[(-30,-30), (0,30), (30,-30)]], #V
[[(-30,-30), (-30,30), (0,0), (30,30), (30,-30)]], #W
[[(-30,30), (30,-30)], [(-30,-30), (30,30)]], #X
[[(0,30), (0,0), (30,-30), (0,0), (-30,-30)]], #Y
[[(30,30), (-30,30), (30,-30), (-30,-30)]], #Z
[[(-2,15), (2,15)]] # Point
]
class Text(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.value = ""
self.zoom = ZOOM_TITLE
def Reset(self):
self.value = ""
def ZoomIn(self):
self.zoom += DZOOM_GAMEOVER
if self.zoom > ZOOM_GAMEOVER:
self.zoom = ZOOM_GAMEOVER
def ZoomOut(self):
self.zoom += DZOOM_PLAYING
if self.zoom < ZOOM_PLAYING:
self.zoom = ZOOM_PLAYING
def ZoomReset(self):
self.zoom = ZOOM_PLAYING
def Draw(self, f):
message = gstt.tmessage
self.DrawChars(f, message)
#print message
def DrawChars(self,f , chars):
#TODO : gérer correctement les coordonnées
l = len(chars)
i= 0
#print chars
#f.LineTo((title_pos[0],title_pos[1]), 0x80000000)
for ch in chars:
i +=1
#print ch
#print i
# texte centre en x automatiquement selon le nombre de lettres l
x_offset = 26 * (- (0.9*l) + 3*i)
#print x_offset
# texte en y selon text_pos dans globalVars
digit_pl_list = ASCII_GRAPHICS[ord(ch) - 47]
for pl in digit_pl_list:
pl_draw = []
for xy in pl:
xy_draw = vectors.Vector2D(text_pos[0],text_pos[1]) + vectors.Vector2D(xy[0] + x_offset,xy[1]) * self.zoom
pl_draw.append(xy_draw.ToTuple())
f.PolyLineOneColor(pl_draw, 0xFFFFFF)