9 struct world_map world_map
;
11 static void world_map_get_dir( v3f dir
){
13 dir
[0] = -sqrtf(0.5f
);
19 static void world_map_get_plane( v4f plane
){
20 world_instance
*world
= &world_static
.instances
[ world_map
.world_id
];
21 f32 h
= localplayer
.rb
.co
[1];
22 if( world_map
.world_id
!= world_static
.active_instance
)
23 h
= (world
->scene_geo
.bbx
[0][1] + world
->scene_geo
.bbx
[1][1]) * 0.5f
;
25 v4_copy( (v4f
){0.0f
,1.0f
,0.0f
,h
}, plane
);
28 static void respawn_world_to_plane_pos( v3f pos
, v2f plane_pos
){
30 world_map_get_dir( dir
);
33 world_map_get_plane( plane
);
36 f32 t
= ray_plane( plane
, pos
, dir
);
37 v3_muladds( pos
, dir
, t
, co
);
42 static void respawn_map_draw_icon( vg_camera
*cam
,
43 enum gui_icon icon
, v3f pos
){
47 m4x4_mulv( cam
->mtx
.pv
, v
, v
);
48 v2_divs( v
, v
[3], v
);
50 gui_draw_icon( icon
, (v2f
){ v
[0]*0.5f
+0.5f
,v
[1]*0.5f
+0.5f
}, 1.0f
);
53 void world_map_pre_update(void)
55 if( skaterift
.activity
!= k_skaterift_world_map
) return;
57 if( button_down( k_srbind_mback
) ){
59 srinput
.state
= k_input_state_resume
;
60 skaterift
.activity
= k_skaterift_menu
;
61 menu
.page
= 0xffffffff;
62 menu_open_page( "Main Menu", k_ent_menuitem_stack_append
);
66 if( button_down( k_srbind_maccept
) ){
67 skaterift
.activity
= k_skaterift_default
;
68 srinput
.state
= k_input_state_resume
;
70 if( world_map
.spawn
){
71 world_static
.active_instance
= world_map
.world_id
;
72 player__spawn( world_map
.spawn
);
77 world_instance
*world
= &world_static
.instances
[ world_map
.world_id
];
78 v3f
*bbx
= world
->scene_geo
.bbx
;
79 f32
*pos
= world_map
.plane_pos
;
82 joystick_state( k_srjoystick_steer
, steer
);
83 v2_normalize_clamp( steer
);
86 m2x2_create_rotation( rm
, -0.25f
*VG_PIf
);
87 m2x2_mulv( rm
, steer
, steer
);
89 v2_muladds( pos
, steer
, vg
.time_frame_delta
* 200.0f
, pos
);
90 v2_minv( (v2f
){ bbx
[1][0], bbx
[1][2] }, pos
, pos
);
91 v2_maxv( (v2f
){ bbx
[0][0], bbx
[0][2] }, pos
, pos
);
94 vg_camera
*cam
= &world_map
.cam
;
96 world_map_get_dir(dir
);
99 world_map_get_plane( plane
);
101 v3f co
= { pos
[0], plane
[3]*plane
[1], pos
[1] };
102 v3_muladds( co
, dir
, world_map
.boom_dist
, cam
->pos
);
104 vg_line_cross( co
, VG__RED
, 10.0f
);
106 cam
->angles
[0] = 0.25f
* VG_PIf
;
107 cam
->angles
[1] = 0.25f
* VG_PIf
;
112 vg_camera_update_transform( cam
);
113 vg_camera_update_view( cam
);
114 vg_camera_update_projection( cam
);
115 vg_camera_finalize( cam
);
118 world_map
.spawn
= NULL
;
119 f32 closest2
= INFINITY
;
121 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_spawn
); i
++ ){
122 ent_spawn
*spawn
= mdl_arritm(&world
->ent_spawn
,i
);
125 v3_copy( spawn
->transform
.co
, v
);
127 m4x4_mulv( cam
->mtx
.pv
, v
, v
);
128 v2_divs( v
, v
[3], v
);
130 f32 d2
= v2_length2(v
);
132 world_map
.spawn
= spawn
;
138 * ---------------------*/
139 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ ){
140 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, i
);
142 enum gui_icon icon
= k_gui_icon_exclaim_2d
;
143 if( challenge
->status
)
144 icon
= k_gui_icon_tick_2d
;
146 respawn_map_draw_icon( cam
, icon
, challenge
->transform
.co
);
149 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_skateshop
); i
++ ){
150 ent_skateshop
*shop
= mdl_arritm( &world
->ent_skateshop
, i
);
151 if( shop
->type
== k_skateshop_type_boardshop
){
152 respawn_map_draw_icon( cam
, k_gui_icon_board
, shop
->transform
.co
);
154 else if( shop
->type
== k_skateshop_type_worldshop
){
155 respawn_map_draw_icon( cam
, k_gui_icon_world
, shop
->transform
.co
);
159 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_gate
); i
++ ){
160 ent_gate
*gate
= mdl_arritm( &world
->ent_gate
, i
);
161 if( gate
->flags
& k_ent_gate_nonlocal
){
162 respawn_map_draw_icon( cam
, k_gui_icon_rift
, gate
->co
[0] );
166 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_route
); i
++ ){
167 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
170 v4_copy( route
->colour
, colour
);
171 v3_muls( colour
, 1.6666f
, colour
);
172 gui_icon_setcolour( colour
);
173 respawn_map_draw_icon( cam
, k_gui_icon_rift_run_2d
,
174 route
->board_transform
[3] );
177 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_glider
); i
++ ){
178 ent_glider
*glider
= mdl_arritm( &world
->ent_glider
, i
);
180 v4f colour
= { 1,1,1,1 };
182 if( !(glider
->flags
& 0x1) )
183 v3_muls( colour
, 0.5f
, colour
);
184 gui_icon_setcolour( colour
);
186 respawn_map_draw_icon( cam
, k_gui_icon_glider
, glider
->transform
.co
);
190 void world_map_enter(void)
192 skaterift
.activity
= k_skaterift_world_map
;
193 world_map
.world_id
= world_static
.active_instance
;
195 world_instance
*world
= &world_static
.instances
[ world_map
.world_id
];
196 v3f
*bbx
= world
->scene_geo
.bbx
;
198 respawn_world_to_plane_pos( localplayer
.rb
.co
, world_map
.plane_pos
);
199 world_map
.boom_dist
= 400.0f
;
200 world_map
.home_select
= 0;
205 if( gui_new_helper( input_joy_list
[k_srjoystick_steer
], &text
) )
206 vg_strcat( &text
, "move" );
208 if( gui_new_helper( input_button_list
[k_srbind_maccept
], &text
) )
209 vg_strcat( &text
, "spawn" );
211 if( gui_new_helper( input_button_list
[k_srbind_mback
], &text
) )
212 vg_strcat( &text
, "exit" );