@@ -262,6 +262,14 @@ function set_fullscreen(value) {
262
262
}
263
263
}
264
264
265
+ curves = {
266
+ 'linear' : ( a , b , t ) => {
267
+ return lerp ( a , b , t ) } ,
268
+
269
+ 'out_expo' : ( a , b , t ) => {
270
+ return lerp ( a , b , t * t ) }
271
+ }
272
+
265
273
ASSETS_FOLDER = ''
266
274
TAPTAPIR_TEXTURES = { }
267
275
entities = [ ]
@@ -697,7 +705,7 @@ class Entity {
697
705
}
698
706
}
699
707
700
- animate ( variable_name , target_value , duration = .1 ) {
708
+ animate ( variable_name , target_value , duration = .1 , curve = curves . linear ) {
701
709
// print('animate:', variable_name, target_value)
702
710
if ( ! this . enabled ) { return false }
703
711
if ( duration <= 1 / 60 ) {
@@ -721,7 +729,8 @@ class Entity {
721
729
if ( ! entity . enabled ) {
722
730
return false }
723
731
var t = i / duration / 60
724
- entity [ variable_name ] = lerp ( start_value , target_value , t )
732
+ // entity[variable_name] = lerp(start_value, target_value, t)
733
+ entity [ variable_name ] = curve ( start_value , target_value , t )
725
734
} ,
726
735
1000 * i / 60
727
736
)
@@ -977,13 +986,13 @@ function goto_scene(scene_name, fade=True) {
977
986
978
987
class HealthBar extends Entity {
979
988
constructor ( options = false ) {
980
- let settings = { min :0 , max :100 , color :'#222222' , bar_color :'bb0505' , scale :[ .8 , .05 ] , roundness :.25 }
989
+ let settings = { min :0 , max :100 , color :'#222222' , bar_color :'bb0505' , scale :[ .8 , .05 ] , roundness :.25 , text_color : '#dddddd' , text_size : 2 }
981
990
for ( const [ key , value ] of Object . entries ( options ) ) {
982
991
settings [ key ] = value
983
992
}
984
993
super ( settings )
985
994
this . bar = new Entity ( { parent :this , origin :[ - .5 , 0 ] , x :- .5 , roundness :.25 , scale_x :.25 , color :settings [ 'bar_color' ] } )
986
- this . text_entity = new Entity ( { parent :this , text :'hii' , text_color :'#dddddd' , color :color . clear , text_origin :[ 0 , 0 ] , text_size :2 } )
995
+ this . text_entity = new Entity ( { parent :this , text :'hii' , text_color :settings [ 'text_color' ] , color :color . clear , text_origin :[ 0 , 0 ] , text_size :settings [ 'text_size' ] } )
987
996
this . value = settings [ 'max' ]
988
997
}
989
998
0 commit comments