void Root::active_update(float dt_sec) { if (mystate == STATE_APPEARING) { if (base_sprite->animation_done()) { hatch_timer.start(HATCH_TIME); mystate = STATE_HATCHING; } } if (mystate == STATE_HATCHING) { if (!hatch_timer.started()) mystate = STATE_GROWING; } else if (mystate == STATE_GROWING) { offset_y -= dt_sec * SPEED_GROW; if (offset_y < static_cast<float>(-m_sprite->get_height())) { offset_y = static_cast<float>(-m_sprite->get_height()); mystate = STATE_SHRINKING; } set_pos(m_start_position + Vector(0, offset_y)); } else if (mystate == STATE_SHRINKING) { offset_y += dt_sec * SPEED_SHRINK; if (offset_y > 0) { offset_y = 0; mystate = STATE_VANISHING; base_sprite->set_action("vanishing", 2); base_sprite->set_animation_loops(2); // TODO: doesn't seem to work for loops=1 } set_pos(m_start_position + Vector(0, offset_y)); } else if (mystate == STATE_VANISHING) { if (base_sprite->animation_done()) remove_me(); } BadGuy::active_update(dt_sec); }
void vsx_widget_profiler_plot::init() { support_interpolation = true; allow_resize_x = true; allow_resize_y = true; set_size(vsx_vector3<>(20.0f,0.3f)); set_pos(vsx_vector3<>(0,0)); this->interpolate_size(); size_min.x = 0.2; size_min.y = 0.2; allow_move_x = false; set_pos(vsx_vector3<>(0,0)); plot_type = v_t; plot_tuple_depth = one_dimension; profiler = vsx_profiler_manager::get_instance()->get_profiler(); title = "plot"; // Menu menu = add(new vsx_widget_popup_menu, ".comp_menu"); menu->commands.adds(VSX_COMMAND_MENU, "close", "menu_close", ""); menu->commands.adds(VSX_COMMAND_MENU, "Plot Type;v_t", "plot_type", "v_t"); menu->size.x = size.x * 0.4; menu->init(); init_run = true; }
void OLEDClass::print_c(uint8_t x, uint8_t y, char c, CharMode mode) { set_pos(x, y); switch (mode) { case C6x8: for (uint8_t i = 0; i < 6; i++) { write(F6x8[c - 32][i], Data_Mode); } break; case C8x16: for (uint8_t i = 0; i < 8; i++) { write(F8x16[c - 32][i], Data_Mode); } set_pos(x, y + 1); for (uint8_t i = 8; i < 16; i++) { write(F8x16[c - 32][i], Data_Mode); } break; case C16x16: for (uint8_t i = 0; i < 16; i++) { write(F16x16[c - 32][i], Data_Mode); } set_pos(x, y + 1); for (uint8_t i = 16; i < 32; i++) { write(F16x16[c - 32][i], Data_Mode); } break; } }
bool Player::unmount() { if (!mount) { return true; } printf_fvec3(get_world_pos()); printf("\n"); mount->remove_entity(this); // try setting pos to about 2 blocks above current position set_pos(fvec3(pos.x, pos.y + 2.0f, pos.z)); if (get_world()->will_collide_with_anything(this)) { // return false if we can't unmount...because not room for player set_pos(fvec3(pos.x, pos.y - 2.0f, pos.z)); mount->add_entity(this); return false; } velocity = mount->velocity; mount = 0; can_collide = true; printf_fvec3(get_world_pos()); get_world()->add_entity(this); toggle_mount(false); return true; }
PyObject* decode_flightpath(const std::string& buf,int version) { Chunk chunk; chunk.deserialize(buf,version); PyObject* d=PyDict_New(); /* startstamp=path['startstamp'] endstamp=path['endstamp'] startpos=path['startpos'] endpos=path['endpos'] distance=path['distance'] path=path['path'] * */ PyObject* thelist=PyList_New(0); for(;;) { PyObject* item=chunk.playback(); if (item==NULL) break; PyList_Append(thelist,item); } set_long(d,"startstamp",chunk.startstamp); set_long(d,"endstamp",chunk.real_endstamp); set_pos(d,"startpos",chunk.start17); set_pos(d,"endpos",chunk.real_endpos); set_float(d,"distance",chunk.distance_millinm/1000.0); PyDict_SetItemString(d,"path",thelist); Py_DECREF(thelist); return d; }
/** * 主函数,显示一些东西 * @return */ int main(void) { uint8_t ch; //0. 初始化LCD init_lcd(); //1. 最简单的字符输出测试 (写数据) set_pos(0x00); write_str("hello world"); _delay_ms(100); //2. 读取数据测试 (读数据) _delay_ms(100); set_pos(0x06); //设置读取的位置,第1行6列,'w'的位置 _delay_ms(1000); ch = get_data(); set_pos(0x0D); //设置光标位置 set_data(ch); _delay_ms(1000); //3. 自定义字符测试 (写内存+读内存) init_chardb(); //初始化自定义的字符集 set_pos(0x40); //设置在第2行还是显示 int i; for ( i =0; i<0b111+1; i++) { set_data(i); //_delay_ms(50); } //4. 读取光标位置 (读地址/位置) I处即光标所在地址 _delay_ms(1000); char str[5]; set_pos(0x4a); ch=get_pos(); sprintf(str,"I=%02XH",ch); write_str(str); return 0; }
// Reads data from the IO, according to the Rack specifications for `#read`. static VALUE tfio_read(int argc, VALUE *argv, VALUE self) { int fd = get_tmpfile(self); size_t pos = get_pos(self); size_t end = get_end(self); VALUE buffer = Qnil; char ret_nil = 0; ssize_t len = 0; // get the buffer object if given if (argc == 2) { Check_Type(argv[1], T_STRING); buffer = argv[1]; } // get the length object, if given if (argc > 0 && argv[0] != Qnil) { Check_Type(argv[0], T_FIXNUM); len = FIX2LONG(argv[0]); if (len < 0) rb_raise(rb_eRangeError, "length should be bigger then 0."); ret_nil = 1; } // return if we're at the EOF. if (pos == end) goto no_data; // calculate length if it wasn't specified. if (len == 0) { // make sure we're not reading more then we have len = end - pos; // set position for future reads set_pos(self, end); if (len == 0) goto no_data; } else { // set position for future reads set_pos(self, pos + len); } // limit read to what we have if (len + pos > end) len = end - pos; // create the buffer if we don't have one. if (buffer == Qnil) { buffer = rb_str_buf_new(len); // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); } else { // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); if (rb_str_capacity(buffer) < len) rb_str_resize(buffer, len); } // read the data. if (pread(fd, RSTRING_PTR(buffer), len, pos) <= 0) goto no_data; rb_str_set_len(buffer, len); return buffer; no_data: if (ret_nil) return Qnil; else return rb_str_buf_new(0); }
void Node2D::set_global_pos(const Point2& p_pos) { Matrix32 inv; CanvasItem *pi = get_parent_item(); if (pi) { inv = pi->get_global_transform().affine_inverse(); set_pos(inv.xform(p_pos)); } else { set_pos(p_pos); } }
static void set_chunk(struct chunk *cnk, struct text *txt, size_t start, size_t size ) { /* Fill the chunk *cnk with info about the piece of text in txt starting at start extending over size tokens. */ cnk->ch_text = txt; set_pos(&cnk->ch_first, 0, txt, start); set_pos(&cnk->ch_last, 1, txt, start + size - 1); }
/****************************************************** * 函数:display_chinese * 作用:显示单个汉字 * 备注: ******************************************************/ void display_chinese(unsigned char row, unsigned char page,unsigned char *c) //row:列 page:页 dd:字符 { unsigned char i; set_pos(row*16, page*2); //写数据 第一行起始地址设定,由于每个字符大小是6*12,占用两行 for(i=0; i<16;i++) LCD_DC(c[i],1);//c代表在zifu数组中的位置 set_pos(row*16, page*2+1);//写数据 第二行起始地址设定 for(i=16; i<32;i++) LCD_DC(c[i],1); }
void LCD1602::disp_time_HMS(uint8_t hour,uint8_t min,uint8_t sec) { char s[8]; set_pos(2,0); disp_string("Time: "); sprintf(s,"%02d:%02d:%02d",hour,min,sec); disp_string(s); set_pos(2,15); disp_char('*'); //第二行结束符显示 }
void FpuStackAllocator::allocate_block(BlockBegin* block) { bool processed_merge = false; LIR_OpList* insts = block->lir()->instructions_list(); set_lir(block->lir()); set_pos(0); // Note: insts->length() may change during loop while (pos() < insts->length()) { LIR_Op* op = insts->at(pos()); _debug_information_computed = false; #ifndef PRODUCT if (TraceFPUStack) { op->print(); } check_invalid_lir_op(op); #endif LIR_OpBranch* branch = op->as_OpBranch(); LIR_Op1* op1 = op->as_Op1(); LIR_Op2* op2 = op->as_Op2(); LIR_OpCall* opCall = op->as_OpCall(); if (branch != NULL && branch->block() != NULL) { if (!processed_merge) { // propagate stack at first branch to a successor processed_merge = true; bool required_merge = merge_fpu_stack_with_successors(block); assert(!required_merge || branch->cond() == lir_cond_always, "splitting of critical edges should prevent FPU stack mismatches at cond branches"); } } else if (op1 != NULL) { handle_op1(op1); } else if (op2 != NULL) { handle_op2(op2); } else if (opCall != NULL) { handle_opCall(opCall); } compute_debug_information(op); set_pos(1 + pos()); } // Propagate stack when block does not end with branch if (!processed_merge) { merge_fpu_stack_with_successors(block); } }
void Logic::create_things(Position p){//生产掉落物品 if(rand()%7 == 0){ auto temp = new Thing(*thing_type[0]); temp->set_pos(p); things.push_back(temp); return;//直接return,如果防止同时出现两个物品 } if(rand()%8 == 0){ auto temp = new Thing(*thing_type[1]); temp->set_pos(p); things.push_back(temp); return; } }
/** Gets returns a line. this is okay for small lines, but shouldn't really be used. Limited to ~ 1Mb of a line length. */ static VALUE tfio_gets(VALUE self) { int fd = get_tmpfile(self); size_t pos = get_pos(self); size_t end = get_end(self); if (pos == end) return Qnil; size_t pos_e = pos; char c; int ret; VALUE buffer; do { ret = pread(fd, &c, 1, pos_e); } while (ret > 0 && c != '\n' && (++pos_e < end)); set_pos(self, pos_e + 1); if (pos > pos_e) { buffer = rb_str_buf_new(pos_e - pos); // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); if (pread(fd, RSTRING_PTR(buffer), pos_e - pos, pos) < 0) return Qnil; rb_str_set_len(buffer, pos_e - pos); return buffer; } return Qnil; }
void Popup::popup_centered_ratio(float p_screen_ratio) { Control *window = get_window(); ERR_FAIL_COND(!window); emit_signal("about_to_show"); Rect2 rect; Point2 window_size = window==this ? get_parent_area_size() :window->get_size(); rect.size = (window_size * p_screen_ratio).floor(); rect.pos = ((window_size-rect.size)/2.0).floor(); set_pos( rect.pos ); set_size( rect.size ); show_modal(exclusive); _fix_size(); Control *focusable = find_next_valid_focus(); if (focusable) focusable->grab_focus(); _post_popup(); notification(NOTIFICATION_POST_POPUP); }
void Buffer_pool_node::reset(){ set_fd(INIT); set_pos(INIT); set_timestamp(INIT); mark_clean(); }
static void change_private_mode(int mode, int set) { switch (mode) { case 1: /* DECCKM */ console->cursor_key_mode = set; break; case 3: if (set) /* 132 column mode */ console_set_size(132, 24); else /* 80 column mode */ console_set_size(80, 24); /* Clear window content and reset scrolling regions */ erase_screen(2); set_pos(0, 0); break; case 6: console->origin_mode = set; break; case 7: console->wraparound_mode = set; break; default: log_error("change_private_mode(): private mode %d not supported.\n", mode); } }
static void console_set_size(int width, int height) { console->top = min(console->top, console->buffer_height - height); COORD size; size.X = width; size.Y = console->buffer_height; SMALL_RECT rect; rect.Left = 0; rect.Right = width - 1; rect.Top = console->top; rect.Bottom = console->top + height - 1; if (width > console->width) { /* Enlarge buffer then window */ SetConsoleScreenBufferSize(console->out, size); SetConsoleWindowInfo(console->out, TRUE, &rect); } else { /* Reduce window then buffer */ SetConsoleWindowInfo(console->out, TRUE, &rect); SetConsoleScreenBufferSize(console->out, size); } set_pos(console->x, console->y); console->width = width; console->height = height; }
/*** RELEASE CURRENT USERSTATE ***/ static void leave_current(void) { switch (curr_state) { case USERSTATE_DRAG: if (curr_release_callback) { curr_release_callback(curr_selected, curr_mx - omx, curr_my - omy); } break; case USERSTATE_TOUCH: if (curr_release_callback) { curr_release_callback(curr_selected, curr_mx - omx, curr_my - omy); } curr_selected->gen->set_state(curr_selected, 0); if (curr_mfocus != curr_selected) { curr_selected->gen->set_mfocus(curr_selected,0); } curr_selected->gen->update(curr_selected); break; case USERSTATE_GRAB: set_pos(omx, omy); scrdrv->set_mouse_pos(omx,omy); break; default: break; } }
void cTtyStatus::OsdStatusMessage(const char *Message) { set_pos(23,0); if (Message) { set_color(BLACK_YELLOW); print(" %-80s", Message); } else { set_color(WHITE_BLACK); print("%-80s", ""); } refresh(); set_pos(2, 0); }
void WindowDialog::_input_event(const InputEvent& p_event) { if (p_event.type == InputEvent::MOUSE_BUTTON && p_event.mouse_button.button_index==BUTTON_LEFT) { if (p_event.mouse_button.pressed && p_event.mouse_button.y < 0) dragging=true; else if (dragging && !p_event.mouse_button.pressed) dragging=false; } if (p_event.type == InputEvent::MOUSE_MOTION && dragging) { Point2 rel( p_event.mouse_motion.relative_x, p_event.mouse_motion.relative_y ); Point2 pos = get_pos(); Size2 size = get_size(); pos+=rel; if (pos.y<0) pos.y=0; set_pos(pos); } }
void Resizer::refresh_pos() { Vector new_pos; switch (vert) { case NONE: new_pos.y = (rect->p1.y + rect->p2.y)/2 - 8; break; case LEFT_UP: new_pos.y = rect->p1.y - 16; break; case RIGHT_DOWN: new_pos.y = rect->p2.y; break; } switch (horz) { case NONE: new_pos.x = (rect->p1.x + rect->p2.x)/2 - 8; break; case LEFT_UP: new_pos.x = rect->p1.x - 16; break; case RIGHT_DOWN: new_pos.x = rect->p2.x; break; } set_pos(new_pos); }
void drawlens(int x0,int y0) { #if 0 int y,ys,ye; long int u1,u2; u1=(x0-lensxs)+(long)(y0-lensys)*320L; u2=(x0-lensxs)+(long)(y0+lensys-1)*320L; ys=lenshig/2; ye=lenshig-1; for(y=0;y<ys;y++) { if(u1>=0 && u1<=64000) { dorow(lens1,(unsigned)u1,y,0x40); dorow2(lens2,(unsigned)u1,y,0x80); dorow2(lens3,(unsigned)u1,y,0xC0); dorow3(lens4,(unsigned)u1,y,0); } u1+=320; if(u2>=0 && u2<=64000) { dorow(lens1,(unsigned)u2,ye-y,0x40); dorow2(lens2,(unsigned)u2,ye-y,0x80); dorow2(lens3,(unsigned)u2,ye-y,0xC0); dorow3(lens4,(unsigned)u2,ye-y,0); } u2-=320; } #endif set_pos(x0, 199 - y0); }
void PopUpMenu::popup(const Point &p_pos) { set_pos(p_pos); show(); set_focus( 0 ); //clear focus }
void PathFollow2D::_update_transform() { if (!path) return; Ref<Curve2D> c =path->get_curve(); if (!c.is_valid()) return; float o = offset; if (loop) o=Math::fposmod(o,c->get_baked_length()); Vector2 pos = c->interpolate_baked(o,cubic); if (rotate) { Vector2 n = (c->interpolate_baked(o+lookahead,cubic)-pos).normalized(); Vector2 t = -n.tangent(); pos+=n*h_offset; pos+=t*v_offset; set_rot(t.atan2()); } else { pos.x+=h_offset; pos.y+=v_offset; } set_pos(pos); }
HitResponse PushButton::collision(GameObject& other, const CollisionHit& hit) { auto player = dynamic_cast<Player*>(&other); if (!player) return FORCE_MOVE; float vy = player->get_physic().get_velocity_y(); //player->add_velocity(Vector(0, -150)); player->get_physic().set_velocity_y(-150); if (state != OFF) return FORCE_MOVE; if (!hit.top) return FORCE_MOVE; if (vy <= 0) return FORCE_MOVE; // change appearance state = ON; float old_bbox_height = m_col.m_bbox.get_height(); set_action("on", -1); float new_bbox_height = m_col.m_bbox.get_height(); set_pos(get_pos() + Vector(0, old_bbox_height - new_bbox_height)); // play sound SoundManager::current()->play(BUTTON_SOUND); // run script Sector::get().run_script(script, "PushButton"); return FORCE_MOVE; }
void Node2D::move_y(float p_delta,bool p_scaled){ Matrix32 t = get_transform(); Vector2 m = t[1]; if (!p_scaled) m.normalize(); set_pos(t[2]+m*p_delta); }
bool Simloid::set_pos (unsigned char motors, unsigned char* id, int* pos, int* speed) throw () { ///< \todo allow setting velocity LWARNING("target velocities not supported by simulation"); for (int i=0; i<motors; i++) set_pos(id[i], pos[i]); return true; }
void MovingSprite::set_action_centered(const std::string& action, int loops) { Vector old_size = bbox.get_size().as_vector(); sprite->set_action(action, loops); set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height()); set_pos(get_pos() - (bbox.get_size().as_vector() - old_size) / 2); }
PneumaticPlatform::PneumaticPlatform(PneumaticPlatform* master) : MovingSprite(*master), master(master), slave(this), start_y(master->start_y), offset_y(-master->offset_y), speed_y(0) { set_pos(get_pos() + Vector(master->get_bbox().get_width(), 0)); master->master = master; master->slave = this; }