ads-game:: made the game easier to (re)start, also more settings

This commit is contained in:
Zeno Rogue 2022-09-18 10:21:13 +02:00
parent 11fe91fb5a
commit 8a35e6facb
2 changed files with 85 additions and 14 deletions

View File

@ -21,6 +21,24 @@ void change_default_key(int key, int val) {
#endif
}
void restart() {
cell *c;
hybrid::in_actual([&] {
vctr = new_vctr = starting_point;
vctrV = new_vctrV = ads_matrix(Id, 0);
init_rsrc();
c = hybrid::get_where(vctr).first;
});
ci_at.clear();
gen_terrain(c, ci_at[c], -2);
forCellEx(c1, c) ci_at[c1].type = wtNone;
ci_at[c].type = wtNone;
ci_at[c].rocks.clear();
}
void run_ads_game() {
change_default_key('s', 16 + 0);
@ -36,22 +54,20 @@ void run_ads_game() {
change_default_key('k', 16 + 10);
change_default_key('l', 16 + 11);
nomap = true;
no_find_player = true;
vctr = new_vctr = cwt.at;
cell *c = hybrid::get_where(vctr).first;
hybrid::in_underlying_geometry([&] {
gen_terrain(c, ci_at[c], -2);
forCellEx(c1, c) ci_at[c1].type = wtNone;
ci_at[c].type = wtNone;
ci_at[c].rocks.clear();
});
vctrV = new_vctrV = ads_matrix(Id, 0);
if(!sl2) set_geometry(gRotSpace);
if(hybrid::csteps) {
stop_game();
hybrid::csteps = 0;
hybrid::reconfigure();
}
start_game();
starting_point = cwt.at;
rogueviz::rv_hook(hooks_frame, 100, view_ads_game);
rogueviz::rv_hook(hooks_prestats, 100, display_rsrc);
rogueviz::rv_hook(hooks_handleKey, 0, handleKey);
rogueviz::rv_hook(shmup::hooks_turn, 0, ads_turn);
init_rsrc();
cgi.use_count++;
hybrid::in_underlying_geometry([] {
@ -68,19 +84,46 @@ void run_ads_game() {
currentmap = umap;
pmodel = mdDisk;
cwt.at = centerover = currentmap->gamestart();
rogueviz::rv_change(nohelp, true);
rogueviz::rv_change(nomenukey, true);
rogueviz::rv_change(nomap, true);
rogueviz::rv_change(no_find_player, true);
restart();
}
void run_ads_game_std() {
set_geometry(gNormal);
set_variation(eVariation::pure);
run_ads_game();
showstartmenu = false;
}
auto shot_hooks =
arg::add3("-ads-game", run_ads_game)
arg::add3("-ads-game1", run_ads_game)
+ arg::add3("-ads-game", run_ads_game_std)
+ addHook(hooks_configfile, 100, [] {
param_f(how_much_invincibility, "ads_invinc")
-> editable(0, TAU, TAU/4, "invincibility time", "How long does the period of invincibility after crashing last, in absolute units.", 'i');
param_b(auto_angle, "ads_auto_angle")
-> editable("automatically rotate the projection", 'a');
param_f(simspeed, "ads_game_simspeed")
-> editable(0, 2*TAU, TAU/4, "game speed", "Controls the speed of the game.", 's');
param_f(accel, "ads_game_accel")
-> editable(0, 30, 1, "acceleration", "Controls the speed of your ship's acceleration.", 'a');
param_f(time_unit, "ads_time_unit")
-> editable(0, 2*TAU, 1, "time unit",
"Controls the unit used when the 'display the proper times' option is on.\n\n"
"It takes tau(=2π) units to go the full circle, so the default time unit is tau. You can also use the absolute units (1)."
, 'a');
param_f(pause_speed, "ads_pause_speed")
-> editable(0, 30, 1, "movement speed while paused", "Controls the speed of camera movement while paused and holding the 'move switch' key.", 'v');
param_b(auto_rotate, "ads_auto_rotate")
-> editable("automatically rotate the screen", 'r');
param_b(view_proper_times, "ads_display")
-> editable("display the proper times", 't');
rsrc_config();
});
}

View File

@ -9,7 +9,7 @@ color_t rsrc_color[6] = {0, 0xC0C0C0FF, 0xFFD500FF, 0xFF0000FF, 0x00FF00FF, 0x00
vector<ld>* rsrc_shape[6] = { nullptr, &shape_heart, &shape_gold, &shape_weapon, &shape_fuel, &shape_airtank };
void init_rsrc() {
void rsrc_config() {
max_pdata.hitpoints = 3;
max_pdata.score = 0;
max_pdata.ammo = 50;
@ -22,7 +22,35 @@ void init_rsrc() {
tank_pdata.fuel = 4 * TAU;
tank_pdata.oxygen = 5 * TAU;
auto all = [] (player_data& d, string s, string t, string u) {
param_i(d.hitpoints, s+"hp")
->editable(0, 10, 3, t + (": hitpoints"), u + ("Hitpoints are drained whenever you are hit."), '1');
param_i(d.ammo, s+"ammo")
->editable(0, 10, 3, t + (": ammo"), u + ("Ammo is drained whenever you shoot."), '1');
param_f(d.fuel, s+"fuel")
->editable(0, 10, 3, t + (": fuel"), u + ("Fuel is drained whenever you thrust."), '1');
param_f(d.oxygen, s+"oxygen")
->editable(0, 10, 3, t + (": oxygen"), u + ("Oxygen is drained whenever continuously."), '1');
};
all(max_pdata, "ads_max_", "maximum", "These control the maximum and initial values of your resources. ");
all(tank_pdata, "ads_tank_", "bonus", "These control the amount of resource in a bonus tank. ");
}
void edit_rsrc() {
auto all = [] (player_data& d) {
add_edit(d.hitpoints);
add_edit(d.ammo);
add_edit(d.fuel);
add_edit(d.oxygen);
};
all(max_pdata);
all(tank_pdata);
}
void init_rsrc() {
pdata = max_pdata;
game_over = false;
}
void display(int id, int y, ld val, ld maxv, ld tank, ld unit) {