Module: Jps
- Defined in:
- ext/jps/rjps.cpp
Class Method Summary collapse
- .clear_map ⇒ Object
- .find_dst_pos(start_x, start_y, end_x, end_y, step) ⇒ Object
- .find_path(start_x, start_y, stop_x, stop_y) ⇒ Object
- .get_map_pos(posX, posY) ⇒ Object
-
.get_path_length(path) ⇒ Object
return INT2FIX(p);.
- .get_path_point(idx) ⇒ Object
- .get_pooled_map_kind_size ⇒ Object
- .get_pooled_map_size(width, height) ⇒ Object
- .init_map(width, height) ⇒ Object
- .set_map_pos(posX, posY, flag) ⇒ Object
Class Method Details
.clear_map ⇒ Object
44 45 46 47 48 49 |
# File 'ext/jps/rjps.cpp', line 44 VALUE clear_map(VALUE self) { clearMap(); clearPath(); return INT2NUM(0); } |
.find_dst_pos(start_x, start_y, end_x, end_y, step) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/jps/rjps.cpp', line 51 VALUE find_dst_pos(VALUE self, VALUE start_x, VALUE start_y, VALUE end_x, VALUE end_y, VALUE step) { if(gmap == NULL) return rb_str_new2("Map is null, plz init gmap first!"); int startX = NUM2INT(start_x); int startY = NUM2INT(start_y); int endX = NUM2INT(end_x); int endY = NUM2INT(end_y); int sp = NUM2INT(step); if(startX < 0 || startX >= gmap->w) return rb_str_new2("startX is overflow!"); if(startY < 0 || startY >= gmap->w) return rb_str_new2("startY is overflow!"); if(endX < 0 || endX >= gmap->w) return rb_str_new2("endX is overflow!"); if(endY < 0 || endY >= gmap->w) return rb_str_new2("endY is overflow!"); JPS::Position ret = findDstPos(startX, startY, endX, endY, sp); VALUE point = rb_ary_new(); rb_ary_push(point, INT2NUM(ret.x)); rb_ary_push(point, INT2NUM(ret.y)); return point; } |
.find_path(start_x, start_y, stop_x, stop_y) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'ext/jps/rjps.cpp', line 11 VALUE find_path(VALUE self, VALUE start_x, VALUE start_y, VALUE stop_x, VALUE stop_y) { if(gmap == NULL) return rb_str_new2("Map is null, plz init gmap first!"); int startX = NUM2INT(start_x); int startY = NUM2INT(start_y); int stopX = NUM2INT(stop_x); int stopY = NUM2INT(stop_y); vector<JPS::Position> * p; p = findPath(startX, startY, stopX, stopY); VALUE arr1 = rb_ary_new(); int i; for(i=0; i< p->size(); ++i) { VALUE arr2 = rb_ary_new(); JPS::Position ret = gpath[i]; rb_ary_push(arr2, INT2NUM(ret.x)); rb_ary_push(arr2, INT2NUM(ret.y)); rb_ary_push(arr1, arr2); } return arr1; // return INT2FIX(p); } |
.get_map_pos(posX, posY) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/jps/rjps.cpp', line 102 VALUE get_map_pos(VALUE self, VALUE posX, VALUE posY) { if(gmap == NULL) return rb_str_new2("Map is null, plz init gmap first!"); int x = NUM2INT(posX); int y = NUM2INT(posY); int fg = getMapPos(x, y); return INT2NUM(fg); } |
.get_path_length(path) ⇒ Object
return INT2FIX(p);
39 40 41 42 |
# File 'ext/jps/rjps.cpp', line 39 VALUE get_path_length(VALUE self, VALUE path) { return INT2NUM(RARRAY_LEN(path)); } |
.get_path_point(idx) ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'ext/jps/rjps.cpp', line 80 VALUE get_path_point(VALUE self, VALUE idx) { int index = NUM2INT(idx); JPS::Position ret = gpath[index]; VALUE point = rb_ary_new(); rb_ary_push(point, INT2NUM(ret.x)); rb_ary_push(point, INT2NUM(ret.y)); return point; } |
.get_pooled_map_kind_size ⇒ Object
122 123 124 125 126 |
# File 'ext/jps/rjps.cpp', line 122 VALUE get_pooled_map_kind_size(VALUE self) { int si = getPooldMapKindSize(); return INT2NUM(si); } |
.get_pooled_map_size(width, height) ⇒ Object
128 129 130 131 132 133 134 |
# File 'ext/jps/rjps.cpp', line 128 VALUE get_pooled_map_size(VALUE self, VALUE width, VALUE height) { int w = NUM2INT(width); int h = NUM2INT(height); int si = getPooldMapSize(w, h); return INT2NUM(si); } |
.init_map(width, height) ⇒ Object
114 115 116 117 118 119 120 |
# File 'ext/jps/rjps.cpp', line 114 VALUE init_map(VALUE self, VALUE width, VALUE height) { int w = NUM2INT(width); int h = NUM2INT(height); initMap(w, h); return INT2NUM(0); } |
.set_map_pos(posX, posY, flag) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/jps/rjps.cpp', line 90 VALUE set_map_pos(VALUE self, VALUE posX, VALUE posY, VALUE flag) { if(gmap == NULL) return rb_str_new2("Map is null, plz init gmap first!"); int x = NUM2INT(posX); int y = NUM2INT(posY); int fg = NUM2INT(flag); setMapPos(x, y, fg); return INT2NUM(0); } |