1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2012-2013 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Improves dino appearance
23 var turning_angle
= 0.0
25 var was_going_left
= false
27 var turning_step
= 0.1
29 redef fun do_turn
( turn
)
34 if going_left
!= was_going_left
then
45 was_going_left
= going_left
48 redef fun draw
( display
, imgs
, turn
)
50 var spos
= pos
.to_screen
( display
)
55 img
= imgs
.dino_dead_img
57 var img_radius
= (img
.width
/2).to_f
59 display
.blit_centered
( imgs
.dino_shadow
, spos
.x
.to_i
, spos
.y
.to_i
)
63 turning_angle
+= turning_step
65 turning_angle
-= turning_step
68 var adx
= turning_angle
.cos
* img_radius
69 var ady
= turning_angle
.sin
* img_radius
# * 0.3
72 var dy
= spos
.y
- ady
- (img
.height
/2).to_f
74 var ay
= spos
.y
+ ady
- (img
.height
/2).to_f
76 var by
= ay
+ img
.height
.to_f
78 var cy
= dy
+ img
.height
.to_f
80 display
.blit_stretched
( img
, ax
, ay
, bx
, by
, cx
, cy
, dx
, dy
)
82 if (going_left
and turning_angle
>= pi
) or
83 (going_right
and turning_angle
<= 0.0)then
87 var dx
= spos
.x
+ img_radius
88 var dy
= spos
.y
- (img
.height
/2).to_f
89 var ax
= spos
.x
- img_radius
92 var by
= dy
+ img
.height
.to_f
97 display
.blit_stretched
( img
, ax
, ay
, bx
, by
, cx
, cy
, dx
, dy
)
99 display
.blit_stretched
( img
, dx
, dy
, cx
, cy
, bx
, by
, ax
, ay
)