本文整理汇总了C++中set_pos函数的典型用法代码示例。如果您正苦于以下问题:C++ set_pos函数的具体用法?C++ set_pos怎么用?C++ set_pos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_pos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
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);
}
示例2: set_size
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;
}
示例3: set_pos
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;
}
}
示例4: printf_fvec3
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;
}
示例5: decode_flightpath
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;
}
示例6: main
/**
* 主函数,显示一些东西
* @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;
}
示例7: tfio_read
// 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);
}
示例8: get_parent_item
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);
}
}
示例9: set_chunk
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);
}
示例10: display_chinese
/******************************************************
* 函数: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);
}
示例11: set_pos
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('*'); //第二行结束符显示
}
示例12: set_lir
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);
}
}
示例13: Thing
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;
}
}
示例14: tfio_gets
/**
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;
}
示例15: get_window
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);
}