void key_handler_setlauncher(struct key *key) { (void)key; launcher_grab(); draw_bars(); }
// Draws the histogram, duh ! void Histogram::draw() const { draw_background(); draw_bars(); draw_scale(); draw_border(); }
void client_focus(Client *c) { if(!c || !ISVISIBLE(c)) { for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); } if(selmon->sel) { client_unfocus(selmon->sel, false); } if(c) { if(c->mon != selmon) { selmon = c->mon; } if(c->isurgent) { client_clear_urgent(c); } client_detach_stack(c); client_attach_stack(c); grabbuttons(c, true); xcb_change_window_attributes(conn, c->win, XCB_CW_BORDER_PIXEL, (uint32_t*)&dc.sel[ColBorder]); xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, c->win, XCB_CURRENT_TIME); } else { xcb_set_input_focus(conn, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME); } selmon->sel = c; draw_bars(); }
//-- Render ------------------------------------------------------------------- // Called once per frame. Do all rendering here. //----------------------------------------------------------------------------- extern "C" void Render() { glDisable(GL_BLEND); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1.5, 10); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glPolygonMode(GL_FRONT, GL_FILL); //glPolygonMode(GL_BACK, GL_FILL); x_angle += x_speed; if(x_angle >= 360.0) x_angle -= 360.0; y_angle += y_speed; if(y_angle >= 360.0) y_angle -= 360.0; z_angle += z_speed; if(z_angle >= 360.0) z_angle -= 360.0; draw_bars(); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); }
void update_bars(void) { sysinfo_update(); dbg_print(__func__); draw_bars(); }
void handler_keypress(XEvent *ev) { XKeyEvent *kev = &ev->xkey; struct key *key; dbg_print(__func__); /* Handle launcher keys */ if (kev->window == launcher_window() && launcher_keypress(kev)) { draw_bars(); return; } for (key = keys; key; key = key->next) { if (key_pressed(key, kev->keycode, kev->state)) { if (key->action >= 0 && key->action < LASTAction && key_handler[key->action]) { key_handler[key->action](key); break; /* Skip further bindings */ } else { die("unhandled key action (%d), fix this!\n", key->action); } } } }
static bool_t draw_cb (GtkWidget * widget, cairo_t * cr) { #ifdef GDK_WINDOWING_X11 if (! s_context) return FALSE; #endif #ifdef GDK_WINDOWING_WIN32 if (! s_glrc) return FALSE; #endif GtkAllocation alloc; gtk_widget_get_allocation (widget, & alloc); glViewport (0, 0, alloc.width, alloc.height); glDisable (GL_BLEND); glMatrixMode (GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glFrustum (-1.1f, 1, -1.5f, 1, 2, 10); glMatrixMode (GL_MODELVIEW); glPushMatrix (); glLoadIdentity (); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); glPolygonMode (GL_FRONT, GL_FILL); glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor (0, 0, 0, 1); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_bars (); glPopMatrix (); glMatrixMode (GL_PROJECTION); glPopMatrix (); glDisable (GL_DEPTH_TEST); glDisable (GL_BLEND); glDepthMask (GL_TRUE); #ifdef GDK_WINDOWING_X11 glXSwapBuffers (s_display, s_xwindow); #endif #ifdef GDK_WINDOWING_WIN32 SwapBuffers (s_hdc); #endif return TRUE; }
//-- Render ------------------------------------------------------------------- // Called once per frame. Do all rendering here. //----------------------------------------------------------------------------- extern "C" void Render() { bool configured = true; //FALSE; g_device->SetRenderState(D3DRS_SRCBLEND , D3DBLEND_ONE); g_device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ZERO); g_device->SetRenderState(D3DRS_AMBIENT, 0xffffffff); g_device->SetRenderState(D3DRS_LIGHTING, FALSE); g_device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); g_device->SetRenderState(D3DRS_ZENABLE, TRUE); g_device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE); g_device->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESS); g_device->SetRenderState(D3DRS_FILLMODE, g_mode); g_device->SetFVF(VERTEX_FORMAT); g_device->SetPixelShader(NULL); g_device->Clear(0, NULL, D3DCLEAR_ZBUFFER, D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f), 1.0f, 0); D3DXMATRIX matProjection; D3DXMatrixPerspectiveOffCenterLH(&matProjection, -1.0f, 1.0f, -1.0f, 1.0f, 1.5f, 10.0f); g_device->SetTransform(D3DTS_PROJECTION, &matProjection); D3DXMATRIX matView; D3DXMatrixIdentity(&matView); g_device->SetTransform(D3DTS_VIEW, &matView); if(configured) { x_angle += x_speed; if(x_angle >= 360.0f) x_angle -= 360.0f; y_angle += y_speed; if(y_angle >= 360.0f) y_angle -= 360.0f; z_angle += z_speed; if(z_angle >= 360.0f) z_angle -= 360.0f; draw_bars(); } }
void propertynotify(XEvent* event) { XPropertyEvent *ev = &event->xproperty; Client* client; if((client = wintosystrayicon(ev->window))) { if(ev->atom == XA_WM_NORMAL_HINTS) updatesystrayicongeom(client, client->last_size.width, client->last_size.height); resizebarwin(get_current_monitor()); updatesystray(); } if((ev->window == gRoot) && (ev->atom == XA_WM_NAME)) update_status(); if (ev->state == PropertyNewValue && (client = get_client_from_window(ev->window))) { if (ev->atom == XA_WM_HINTS) client_update_wm_hints(client); else if (ev->atom == XA_WM_NAME) client_update_title(client); } draw_bars(); }
void fountain() { char line[DEFLEN]; char liquid[DEFLEN]; char * insert; int temp; int blood; int rlen; blood = (gtile(player->y, player->x) == TL_P_BLOOD_FOUNTAIN); snprintf(liquid, DEFLEN, "%s", blood ? "BLOOD" : "WATER"); stile(player->y, player->x, TL_FOUNT_BASE); stile(player->y - 1, player->x, TL_VOID); stile(player->y - 2, player->x, TL_VOID); stile(player->y - 2, player->x - 1, TL_VOID); stile(player->y - 2, player->x + 1, TL_VOID); snprintf(line, DEFLEN, "YOU DRINK FROM THE %sFOUNTAIN\n\n", (blood ? "BLOOD " : "")); rlen = strlen(line); insert = &line[rlen]; rlen = DEFLEN - rlen; draw_board(); switch (rand() % 10) { case 0: snprintf(insert, rlen, "THE %s TASTES FOUL!!", liquid); pwait(line); player->flags = GFX_HURT; draw_board(); lpause(); player->flags = 0; player->hp -= 1 + rand() % 10; draw_bars(); if (player->hp <= 0) { draw_board(); game_over("YOU DIED FROM A\n" "POISONED FOUNTAIN", false); } break; case 1: snprintf(insert, rlen, "THE %s TASTES BITTER!\n\nYOU FEEL SLOWER!", liquid); pwait(line); change_pl_sp(-1); draw_stats(); break; case 2: case 3: temp = 100 + (rand() % 5) * 100; temp += MAX(0, game->current_floor - 7) * 100; snprintf(insert, rlen, "THIS IS A FOUNTAIN OF WISDOM!\n\n" "YOU GET %d EXP", temp); pwait(line); draw_board(); give_exp(temp); break; case 4: case 5: snprintf(insert, rlen, "THE %s IS INVIGORATING!\n\nYOU FEEL STRONGER!", liquid); pwait(line); change_pl_st(+1); draw_stats(); break; default: snprintf(insert, rlen, "THE %s IS REFRESHING!", liquid); pwait(line); refill_hp(FOUNTAIN_HEAL); break; } return; }
void altar() { char line[DEFLEN]; int temp; char * p; stile(player->y, player->x, TL_GR_HL); /* Praying increases piety (hidden from the player); when the player has enough it will cause a beneficial effect. If the player chooses to loot the altar they will lose all piety. */ if (psel("YOU APPROACH THE ALTAR\n" "\n" "<- LOOT IT#PRAY ->") == 0) { stile(player->y - 2, player->x - 3, TL_VOID); stile(player->y - 2, player->x + 3, TL_VOID); stile(player->y - 3, player->x, TL_VOID); stile(player->y - 2, player->x - 1, TL_VOID); stile(player->y - 2, player->x, TL_VOID); stile(player->y - 2, player->x + 1, TL_VOID); draw_board(); give_gold("YOU LOOT THE ALTAR\n\n", 1 + rand() % ALTAR_LOOT_GOLD); game->piety -= ALTAR_LOOT_PENALTY + (rand() % ALTAR_LOOT_PENALTY); if (game->piety < -3000 && rand() % 3 == 0) { draw_board(); pwait("A MIGHTY VOICE BOOMS OUT:\n" "\"THOU HATH DEFILED MY ALTAR\n" " TOO MANY TIMES, MORTAL!\""); draw_board(); if (rand() % 2 == 0) { pwait("YOU ARE STRUCK BY LIGHTNING!"); draw_board(); lightning(player->y - view_y, player->x - view_x); player->hp -= 25 + rand() % 46; if (player->hp <= 0) game_over("YOU DIED FOR YOUR SINS", false); draw_bars(); } else { pwait("YOU FEEL WEAK!"); player->strength = MAX(1, player->strength - 1 - rand() % 3); player->speed = MAX(1, player->speed - 1 - rand() % 3); } } else if (game->piety < -2000 && rand() % 3 == 0) { tremor(5); draw_board(); pwait("YOU HEAR A RUMBLE IN THE DISTANCE"); } else if (game->piety < -1000 && rand() % 3 == 0) { draw_board(); pwait("YOU GET AN UNEASY FEELING"); } } else { stile(player->y - 3, player->x - 1, TL_YDOT); stile(player->y - 3, player->x, TL_YDOT); stile(player->y - 3, player->x + 1, TL_YDOT); // Update board with lit candles draw_board(); strcpy(line, "YOU PRAY AT THE ALTAR"); if (game->piety < 0) game->piety += 500; game->piety += ALTAR_PRAYER_PIETY + (rand() % ALTAR_PRAYER_PIETY); if (game->piety < 0) { strcat(line, "\n\nYOU ARE LEFT WITH A DISAPPROVING\n" "SENSATION OF EMPTINESS"); pwait(line); } else if (rand() % MAX(1, game->piety) > ALTAR_HEAL_PIETY) { game->piety -= ALTAR_HEAL_PIETY; strcat(line, "\n\n YOU ARE EMBRACED BY\n" " A WARM FEELING! "); pwait(line); draw_board(); refill_hp(ALTAR_EMBRACE_HEAL); } else if (rand() % MAX(1, game->piety) > ALTAR_WISDOM_PIETY) { game->piety -= ALTAR_WISDOM_PIETY; temp = (1 + rand() % game->current_floor) * 100; temp += MAX(0, game->current_floor - 7) * 200; // Find end of string for (p = line; *p != '\0'; p++) { } sprintf(p, "\n\nYOU HAVE BEEN ENLIGHTENED!\n\n" "YOU GET %d EXP", temp); pwait(line); draw_board(); give_exp(temp); } else { pwait(line); } } return; }
void *draw_thread_func(void *arg) { Bool configured = FALSE; if ((window = create_window(640, 480)) == 0) { g_log(NULL, G_LOG_LEVEL_CRITICAL, __FILE__ ": unable to create window"); pthread_exit(NULL); } XMapWindow(dpy, window); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1.5, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); #ifdef HAVE_SCHED_SETSCHEDULER if(xmms_check_realtime_priority()) { struct sched_param sparam; sparam.sched_priority = sched_get_priority_max(SCHED_OTHER); pthread_setschedparam(pthread_self(), SCHED_OTHER, &sparam); } #endif while(going) { while(XPending(dpy)) { XEvent event; KeySym keysym; char buf[16]; XNextEvent(dpy, &event); switch(event.type) { case ConfigureNotify: glViewport(0,0,event.xconfigure.width, event.xconfigure.height); if(oglspectrum_cfg.tdfx_mode && !grabbed_pointer) { XGrabPointer(dpy, window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); grabbed_pointer = TRUE; } configured = TRUE; break; case KeyPress: XLookupString (&event.xkey, buf, 16, &keysym, NULL); switch(keysym) { case XK_Escape: /* Ugly hack to get the disable_plugin call in the main thread. */ GDK_THREADS_ENTER(); gtk_idle_add(disable_func, NULL); GDK_THREADS_LEAVE(); break; case XK_z: xmms_remote_playlist_prev(oglspectrum_vp.xmms_session); break; case XK_x: xmms_remote_play(oglspectrum_vp.xmms_session); break; case XK_c: xmms_remote_pause(oglspectrum_vp.xmms_session); break; case XK_v: xmms_remote_stop(oglspectrum_vp.xmms_session); break; case XK_b: xmms_remote_playlist_next(oglspectrum_vp.xmms_session); break; case XK_Up: x_speed -= 0.1; if(x_speed < -3.0) x_speed = -3.0; break; case XK_Down: x_speed += 0.1; if(x_speed > 3.0) x_speed = 3.0; break; case XK_Left: y_speed -= 0.1; if(y_speed < -3.0) y_speed = -3.0; break; case XK_Right: y_speed += 0.1; if(y_speed > 3.0) y_speed = 3.0; break; case XK_w: z_speed -= 0.1; if(z_speed < -3.0) z_speed = -3.0; break; case XK_q: z_speed += 0.1; if(z_speed > 3.0) z_speed = 3.0; break; case XK_Return: x_speed = 0.0; y_speed = 0.5; z_speed = 0.0; x_angle = 20.0; y_angle = 45.0; z_angle = 0.0; break; } break; case ClientMessage: if ((Atom)event.xclient.data.l[0] == wm_delete_window_atom) { GDK_THREADS_ENTER(); gtk_idle_add(disable_func, NULL); GDK_THREADS_LEAVE(); } break; } } if(configured) { x_angle += x_speed; if(x_angle >= 360.0) x_angle -= 360.0; y_angle += y_speed; if(y_angle >= 360.0) y_angle -= 360.0; z_angle += z_speed; if(z_angle >= 360.0) z_angle -= 360.0; draw_bars(); } } if (glxcontext) { glXMakeCurrent(dpy, 0, NULL); glXDestroyContext(dpy, glxcontext); glxcontext = NULL; } if (window) { if (grabbed_pointer) { XUngrabPointer(dpy, CurrentTime); grabbed_pointer = FALSE; } XDestroyWindow(dpy, window); window = 0; } pthread_exit(NULL); }
void kill_enemy(mob_t * target) { char line[DEFLEN]; bool boss = false; if (target->type == MOB_ARCHDEMON) boss = true; game->monsters_killed++; /* // This shouldn't be needed anymore with monster packing if (target->type == MOB_BRICKWALL) { // Remove the hidden placeholders so creatures can move through the cleared area stile(target->y, target->x - 3, TL_VOID); stile(target->y, target->x + 3, TL_VOID); } */ if (boss) { snprintf(line, DEFLEN, "YOU HAVE SLAIN %s%s!!!", article[target->article], mob_name[target->type]); /* Don't remove boss */ } else { snprintf(line, DEFLEN, "YOU HAVE SLAIN %s%s\n" "\n" "YOU GET %d EXP", article[target->article], mob_name[target->type], target->exp); target->type = MOB_NONE; } draw_board(); enemy_bar = -1; draw_bars(); pwait(line); draw_board(); if (boss) { pwait("YOU HAVE WON!!!"); game_over(NULL, true); //shutdown(); // exit(0); } give_exp(target->exp); return; }
int shoot_missile(mob_t * attacker, int dir) { char line[DEFLEN]; mob_t * target; int m_y; int m_x; int sc_y; int sc_x; int count; int m_type; int adjust_y; int passes; int pass; int xbow; chtype color; chtype missile; // attacker = &game->mob[mi]; xbow = false; passes = 1; adjust_y = water_offset(attacker); m_y = attacker->y; sc_y = m_y - view_y - 1; m_x = attacker->x + (attacker->flip ? -attacker->pack_w + 2 : attacker->pack_w - 2) + dir * 2; if (attacker->type == MOB_EYE) { m_type = MIS_DISINT; sc_y -= 1; m_x = attacker->x; } else if (attacker->type == MOB_LICH) { m_type = MIS_FIREBALL; sc_y -= 1; } else if (attacker == player) { if (game->weapon == WPN_BOW) m_type = MIS_ARROW; else if (game->weapon == WPN_3XBOW) { xbow = true; m_type = MIS_ARROW; if (water_offset(attacker)) passes = 2; else passes = 3; } else if (game->weapon == WPN_BLASTER) { m_type = MIS_BLASTER; adjust_y -= 1; } } else { m_type = MIS_ARROW; } draw_board(); for (pass = 0; pass < passes; pass++) { count = 0; if (xbow) { m_x = attacker->x + (attacker->flip ? -attacker->pack_w + 2 : attacker->pack_w - 2) + dir * 2; if (pass == 0) adjust_y = water_offset(attacker) - 1; else if (pass == 1) adjust_y = water_offset(attacker); else if (pass == 2) adjust_y = water_offset(attacker) + 1; } while (1) { m_x += dir; sc_x = m_x - view_x; count++; if (sc_x < 0 || sc_x >= BOARD_W) goto end_pass;//break;//return 0; target = find_enemy(attacker, m_y, m_x + dir); if (target == NULL) { if (game->blinded) continue; if (m_type != MIS_BLASTER && count % 2 == 1) continue; // Skip the length of the barrel if (m_type == MIS_BLASTER && count < 4) continue; missile = '?'; color = COLOR_PAIR(PAIR_GREEN); if (m_type == MIS_ARROW) { missile = '-'; color = COLOR_PAIR(PAIR_MAGENTA); } if (m_type == MIS_BLASTER) { missile = '='; color = COLOR_PAIR(PAIR_MAGENTA); } else if (m_type == MIS_FIREBALL) { missile = '*'; color = COLOR_PAIR(PAIR_RED); } else if (m_type == MIS_DISINT) { missile = (dir > 0 ? '>' : '<'); color = COLOR_PAIR(PAIR_RED); } if (water_join(gtile(m_y - 1, m_x))) { color = COLOR_PAIR(PAIR_BLACK_ON_CYAN); } if (m_type == MIS_BLASTER) { mvwaddch(board, sc_y + adjust_y, sc_x, '_' | color); /* if (count % 2) mvwaddch(board, sc_y, sc_x, (dir > 0 ? ')' : '(') | color); else mvwaddch(board, sc_y - 1, sc_x, (dir > 0 ? ')' : '(') | color);*/ } else mvwaddch(board, sc_y + adjust_y, sc_x, missile | color); wrefresh(board); spause(); continue; } if (target->shd_up && ((!target->flip && dir < 0) || (target->flip && dir > 0)) ) { if (target == player && m_type == MIS_DISINT && target->shd_type != SHD_NONE && target->shd_type != SHD_MAGIC) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", armor_name[target->shd_type]); pwait(line); target->shd_type = SHD_NONE; target->shd_up = false; goto end_pass;//return true; } if (m_type != MIS_BLASTER && shield_block(target)) { mob_text(target, "BLOCK"); damage_shield(target); goto end_pass; //return true; } } if (target == player && m_type == MIS_DISINT) { if (target->armor_type != ARMOR_NONE && target->armor_type != ARMOR_MAGIC) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", armor_name[target->armor_type]); pwait(line); target->armor_type = ARMOR_NONE; goto end_pass;// return true; } if (game->weapon != WPN_UNARMED) { flush_input(); snprintf(line, DEFLEN, "DISINTEGRATION BEAM!!\n\nYOUR %s\nCRUMBLES TO DUST!", weapon_name[game->weapon]); pwait(line); give_weapon(WPN_UNARMED); goto end_pass; //return true; } } damage(attacker, target); if (m_type == MIS_ARROW) { target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; } else if (m_type == MIS_BLASTER) { target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; } else if (m_type == MIS_FIREBALL) { explosion(sc_y, sc_x + dir); } if (target == player) { draw_bars(); } if (target->hp <= 0) { if (target == player) { snprintf(line, DEFLEN, "YOU WERE %s\n" "BY %s%s", (m_type == MIS_FIREBALL ? "FRIED" : (m_type == MIS_DISINT ? "DISINTEGRATED" : "SHOT")), article[attacker->article], mob_name[attacker->type]); draw_board(); game_over(line, false); } else { if (!xbow || pass == passes - 1) kill_enemy(target); goto end_pass; } } else if (target != player) { enemy_bar = target->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); // update the number of eyes it has if (target->type == MOB_BIGSPIDER) draw_board();// draw_board(); } damage_armor(target); goto end_pass; } end_pass: continue; } // return 1; // } return 1; }
static void * draw_thread_func(void * UNUSED (arg)) { Bool configured = FALSE; window_w = prefs_get_int(ap_prefs, "opengl_spectrum", "width", DEFAULT_W); window_h = prefs_get_int(ap_prefs, "opengl_spectrum", "height", DEFAULT_H); if ((window = create_window(window_w, window_h)) == 0) { alsaplayer_error("unable to create window"); pthread_exit(NULL); } XMapWindow(dpy, window); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1, 1, -1, 1, 1.5, 10); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); while(going) { while(XPending(dpy)) { XEvent event; KeySym keysym; char buf[16]; XNextEvent(dpy, &event); switch(event.type) { case ConfigureNotify: glViewport(0,0,event.xconfigure.width, event.xconfigure.height); window_w = event.xconfigure.width; window_h = event.xconfigure.height; prefs_set_int(ap_prefs, "opengl_spectrum", "width", window_w); prefs_set_int(ap_prefs, "opengl_spectrum", "height", window_h); configured = TRUE; break; case KeyPress: XLookupString (&event.xkey, buf, 16, &keysym, NULL); switch(keysym) { case XK_Escape: going = FALSE; break; case XK_z: /*xmms_remote_playlist_prev(oglspectrum_vp.xmms_session); */ break; case XK_x: /*xmms_remote_play(oglspectrum_vp.xmms_session); */ break; case XK_c: /*xmms_remote_pause(oglspectrum_vp.xmms_session); */ break; case XK_v: /*xmms_remote_stop(oglspectrum_vp.xmms_session); */ break; case XK_b: /* xmms_remote_playlist_next(oglspectrum_vp.xmms_session); */ break; case XK_Up: x_speed -= 0.1; if(x_speed < -3.0) x_speed = -3.0; break; case XK_Down: x_speed += 0.1; if(x_speed > 3.0) x_speed = 3.0; break; case XK_Left: y_speed -= 0.1; if(y_speed < -3.0) y_speed = -3.0; break; case XK_Right: y_speed += 0.1; if(y_speed > 3.0) y_speed = 3.0; break; case XK_w: z_speed -= 0.1; if(z_speed < -3.0) z_speed = -3.0; break; case XK_q: z_speed += 0.1; if(z_speed > 3.0) z_speed = 3.0; break; case XK_Return: x_speed = 0.0; y_speed = 0.5; z_speed = 0.0; x_angle = 20.0; y_angle = 45.0; z_angle = 0.0; break; } break; case ClientMessage: if ((Atom)event.xclient.data.l[0] == wm_delete_window_atom) { going = FALSE; } break; } } if(configured) { x_angle += x_speed; if(x_angle >= 360.0) x_angle -= 360.0; y_angle += y_speed; if(y_angle >= 360.0) y_angle -= 360.0; z_angle += z_speed; if(z_angle >= 360.0) z_angle -= 360.0; draw_bars(); } } if (glxcontext) { glXMakeCurrent(dpy, 0, NULL); glXDestroyContext(dpy, glxcontext); glxcontext = NULL; } if (window) { if (grabbed_pointer) { XUngrabPointer(dpy, CurrentTime); grabbed_pointer = FALSE; } XDestroyWindow(dpy, window); window = 0; } pthread_mutex_unlock(&scope_mutex); stop_display(0); /* Close down display */ pthread_exit(NULL); }
void idol() { stile(player->y, player->x, TL_IDOL_BASE); if (psel("YOU FIND THE BLOOD-STAINED IDOL\n" "OF A DARK AND NAMELESS GOD\n" "\n" "<- SMASH IT#SACRIFICE ->") == 0) { decorate(player->y, player->x, DEC_BROKEN_IDOL); game->piety += IDOL_SMASH_PIETY + rand() % IDOL_SMASH_PIETY; game->sacrifice -= IDOL_SACRIFICE_PEN; } else { stile(player->y - 3, player->x, TL_IDOL_HEAD_LIT); player->hp--; draw_bars(); draw_board(); pwait("YOU DRAW A SINGLE DROP\n" "OF BLOOD AS TRIBUTE"); game->sacrifice += IDOL_SACRIFICE_GAIN; game->piety -= IDOL_SMASH_PIETY + rand() % IDOL_SMASH_PIETY; if (player->hp <= 0) { draw_board(); pwait("YOU HAVE GIVEN YOUR LIFE!!!"); draw_board(); game_over("YOU SACRIFICED YOURSELF\n" "TO A DARK AND NAMELESS GOD", false); } else if (rand() % MAX(1, game->sacrifice) > IDOL_SACRIFICE_LIMIT) { draw_board(); game->sacrifice -= IDOL_SACRIFICE_LIMIT; draw_board(); switch(rand() % 2) { case 0: pwait("YOU HAVE BEEN REWARDED"); refill_hp(IDOL_HP_REFILL); break; case 1: pwait("YOU HEAR A MOCKING LAUGHTER"); refill_hp(5); player->strength = MAX(1, player->strength - 4 + rand() % 9); player->speed = MAX(1, player->speed - 4 + rand() % 9); break; } } } return; }
void vis::SpectrumTransformer::execute(pcm_stereo_sample *buffer, vis::NcursesWriter *writer, const bool is_stereo) { const auto win_height = NcursesUtils::get_window_height(); const auto win_width = NcursesUtils::get_window_width(); auto right_margin = static_cast<int32_t>( m_settings->get_spectrum_right_margin() * win_width); auto left_margin = static_cast<int32_t>( m_settings->get_spectrum_left_margin() * win_width); auto width = win_width - right_margin - left_margin; bool is_silent_left = true; bool is_silent_right = true; if (is_stereo) { is_silent_left = prepare_fft_input(buffer, m_settings->get_sample_size(), m_fftw_input_left, vis::ChannelMode::Left); is_silent_right = prepare_fft_input(buffer, m_settings->get_sample_size(), m_fftw_input_right, vis::ChannelMode::Right); } else { is_silent_left = prepare_fft_input(buffer, m_settings->get_sample_size(), m_fftw_input_left, vis::ChannelMode::Both); } if (!(is_silent_left && is_silent_right)) { m_silent_runs = 0; } // if there is no sound, do not do any processing and sleep else { ++m_silent_runs; } if (m_silent_runs < k_max_silent_runs_before_sleep) { m_fftw_plan_left = fftw_plan_dft_r2c_1d( static_cast<int>(m_settings->get_sample_size()), m_fftw_input_left, m_fftw_output_left, FFTW_ESTIMATE); if (is_stereo) { m_fftw_plan_right = fftw_plan_dft_r2c_1d( static_cast<int>(m_settings->get_sample_size()), m_fftw_input_right, m_fftw_output_right, FFTW_ESTIMATE); } std::wstring bar_row_msg = create_bar_row_msg(m_settings->get_spectrum_character(), m_settings->get_spectrum_bar_width()); uint32_t number_of_bars = static_cast<uint32_t>(std::floor( static_cast<uint32_t>(width) / (bar_row_msg.size() + m_settings->get_spectrum_bar_spacing()))); fftw_execute(m_fftw_plan_left); if (is_stereo) { fftw_execute(m_fftw_plan_right); } auto top_margin = static_cast<int32_t>( m_settings->get_spectrum_top_margin() * win_height); auto height = win_height; height -= top_margin; if (is_stereo) { height = height / 2; } create_spectrum_bars(m_fftw_output_left, m_fftw_results, height, width, number_of_bars, m_bars_left, m_bars_falloff_left); create_spectrum_bars(m_fftw_output_right, m_fftw_results, height, width, number_of_bars, m_bars_right, m_bars_falloff_right); // clear screen before writing writer->clear(); auto max_bar_height = height; if (is_stereo) { ++max_bar_height; // add one so that the spectrums overlap in the // middle } draw_bars(m_bars_left, m_bars_falloff_left, max_bar_height, true, bar_row_msg, writer); draw_bars(m_bars_right, m_bars_falloff_right, max_bar_height, false, bar_row_msg, writer); writer->flush(); fftw_destroy_plan(m_fftw_plan_left); if (is_stereo) { fftw_destroy_plan(m_fftw_plan_right); } } else { VIS_LOG(vis::LogLevel::DEBUG, "No input, Sleeping for %d milliseconds", VisConstants::k_silent_sleep_milliseconds); std::this_thread::sleep_for(std::chrono::milliseconds( VisConstants::k_silent_sleep_milliseconds)); } }
bool melee(mob_t * attacker, int speed) { char line[DEFLEN]; mob_t * target; int att_x; int range; int i; range = attacker->range; att_x = attacker->x; if (speed > 0) att_x++; for (i = 0; i < range; i++) { att_x += speed; target = find_enemy(attacker, player->y, att_x); if (target == NULL) continue; if (target->type == MOB_MIMIC && target->attack_phase == 0) { pwait("WAIT! THAT IS A SMALL MIMIC!"); target->attack_phase = 1; target->flags = 0; return true; } else if (target->type == MOB_BLURK && target->attack_phase == 0) { draw_board_norefresh(); pwait("OH NO! AN INSIDIOUS BLURK BARS YOUR WAY!"); target->attack_phase = 1; target->flags = 0; return true; } // Attack! // The attacker must always lower their shield attacker->shd_up = 0; if (attacker == player && game->weapon > WPN_UNARMED) { damage_weapon(1); } // If the target has their shield up and they are facing each other if (target->shd_up && target->flip != attacker->flip) { if (shield_block(target)) { mob_text(target, "BLOCK"); damage_shield(target); if (target->type == MOB_KNAVE) { if (target->attack_phase == 0) target->attack_phase = 1; else if (target->attack_phase == 1 || target->attack_phase == 2) { move_towards_player(target); } } return true; } } damage(attacker, target); if (attacker->attack_frames == 2) { attacker->flags = GFX_ATTACK2; draw_board(); lpause(); attacker->flags = 0; } attacker->flags = GFX_ATTACK; draw_board(); lpause(); attacker->flags = 0; damage_armor(target); // Draining dagger restores attacker HP if (attacker == player && game->weapon == WPN_DRAIN) { attacker->hp += 1; } if (target->hp > 0) { // Keep track of who we are fighting if (attacker == player) { enemy_bar = target->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); } else if (target == player) { enemy_bar = attacker->index; enemy_bar_time = BAR_TIMEOUT; draw_bars(); } } target->flags = GFX_HURT; draw_board(); lpause(); target->flags = 0; if (target->hp <= 0) { if (target == player) { snprintf(line, DEFLEN, "YOU WERE %s\n" "BY %s%s", attacker->killverb, article[attacker->article], mob_name[attacker->type]); draw_bars(); game_over(line, false); } else { kill_enemy(target); } } if (attacker->type == MOB_ROGUE && game->player_gold > ROGUE_STEAL_GOLD && rand() % 100 < ROGUE_STEAL_CHANCE) { rogue_escape(attacker); } return true; } return false; }