File tree Expand file tree Collapse file tree
external_library/java/hype Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #encoding: utf-8
2+ load_library :hype
3+ include_package 'hype'
4+ java_import 'hype.extended.behavior.HOrbiter3D'
5+ java_import 'hype.extended.behavior.HOscillator'
6+ java_import 'hype.extended.colorist.HColorPool'
7+
8+ PALETTE = %w( #FFFFFF #F7F7F7 #ECECEC #CCCCCC #999999 #666666 #4D4D4D #333333 #FF3300 #FF6600 ) . freeze
9+ attr_reader :pool
10+
11+ def settings
12+ size ( 640 , 640 , P3D )
13+ end
14+
15+ def setup
16+ sketch_title 'Sprite'
17+ H . init ( self )
18+ H . background ( color ( '#242424' ) )
19+ H . use3D ( true )
20+ @pool = HDrawablePool . new ( 400 )
21+ pool . auto_add_to_stage
22+ . add ( HSprite . new ( 50 , 50 ) . texture ( HImage . new ( data_path ( 'tex1.png' ) ) ) )
23+ . add ( HSprite . new ( 50 , 50 ) . texture ( HImage . new ( data_path ( 'tex2.png' ) ) ) )
24+ . add ( HSprite . new ( 50 , 50 ) . texture ( HImage . new ( data_path ( 'tex3.png' ) ) ) )
25+ . colorist ( HColorPool . new ( web_to_color_array ( PALETTE ) ) . fill_only )
26+ . on_create do |obj |
27+ i = pool . current_index
28+ obj . anchorAt ( H ::CENTER ) . rotation ( 45 )
29+ orb = HOrbiter3D . new ( width / 2 , height / 2 , 0 )
30+ . target ( obj )
31+ . radius ( 225 )
32+ . ySpeed ( 1 )
33+ . zSpeed ( 1 )
34+ . yAngle ( ( i + 1 ) *2 )
35+ . zAngle ( ( i + 1 ) *3 )
36+ HOscillator . new
37+ . target ( obj )
38+ . property ( H ::SCALE )
39+ . range ( 0.1 , 1.0 )
40+ . speed ( 0.1 )
41+ . freq ( 10 )
42+
43+
44+ HOscillator . new
45+ . target ( obj )
46+ . property ( H ::ROTATION )
47+ . range ( -180 , 180 )
48+ . speed ( 0.1 )
49+ . freq ( 10 )
50+ . current_step ( i )
51+ end . request_all
52+ end
53+
54+ def draw
55+ H . draw_stage
56+ sketch_title ( format ( 'HSprite %d fps' , frame_rate ) )
57+ end
You can’t perform that action at this time.
0 commit comments