diff options
author | epoch <epoch@hacking.allowed.org> | 2018-03-29 18:29:59 -0500 |
---|---|---|
committer | epoch <epoch@hacking.allowed.org> | 2018-03-29 18:29:59 -0500 |
commit | b062aa0323ed43590edf004648e43e703ff9089e (patch) | |
tree | ba21040fbe944b8fe2484b36c2740221b9cf118e | |
parent | b9eb9e76dbea73cf8ee0d0914990596cd8040eb1 (diff) | |
download | hackvr-b062aa0323ed43590edf004648e43e703ff9089e.tar.gz hackvr-b062aa0323ed43590edf004648e43e703ff9089e.zip |
fixed a bug that caused glitch art from uninitialized memory in the clean backbuffer and added mouse-over and actioning for circles. and commented out "move forward" because I don't have that yet.
-rw-r--r-- | src/graphics_cs_x11.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/graphics_cs_x11.c b/src/graphics_cs_x11.c index df4df49..f17cc5c 100644 --- a/src/graphics_cs_x11.c +++ b/src/graphics_cs_x11.c @@ -91,6 +91,12 @@ void draw_cs_shape(cs_s_t s) {//this is implemented as draw_cs_line... hrm. it c //circle h=max(s.p[0].x,s.p[1].x)-min(s.p[0].x,s.p[1].x); XDrawArc(x11_global.dpy,x11_global.backbuffer,x11_global.backgc,s.p[0].x-h,s.p[0].y-h,h*2,h*2,0,360*64); + if(distance2((c2_t){s.p[0].x,s.p[1].y},(c2_t){gra_global.mousex,gra_global.mousey} ) < h) { + if(gra_global.buttonpressed) { + printf("%s action %s\n",global.user,s.id); + } + XDrawArc(x11_global.dpy,x11_global.backbuffer,x11_global.backgc,s.p[0].x-h-2,s.p[0].y-h-2,h*2+4,h*2+4,0,360*64); + } break; default: for(i=0;i<s.len+(s.len==1);i++) {//this shape is closed! @@ -248,7 +254,7 @@ void x11_keypress_handler(XKeyEvent *xkey,int x,int y) { tmpx=WALK_SPEED*sin(tmprad.r);//cos(0)==1 tmpz=WALK_SPEED*cos(tmprad2.r);//sin(0)==0 snprintf(line,sizeof(line)-1,"%s move +%f +0 +%f\n",global.user,tmpx,tmpz); - snprintf(line,sizeof(line)-1,"%s move forward\n",global.user); + //snprintf(line,sizeof(line)-1,"%s move forward\n",global.user); selfcommand(line); break; case XK_Down: @@ -440,7 +446,7 @@ int graphics_sub_init() { XSetBackground(x11_global.dpy, x11_global.gc, x11_global.colors[160].pixel); XSetBackground(x11_global.dpy, x11_global.backgc, x11_global.colors[140].pixel); - XFillRectangle(x11_global.dpy, x11_global.cleanbackbuffer,x11_global.backgc,0,0,gra_global.width,gra_global.height); + XFillRectangle(x11_global.dpy, x11_global.cleanbackbuffer,x11_global.backgc,0,0,MAXWIDTH,MAXHEIGHT); XSetForeground(x11_global.dpy, x11_global.backgc,x11_global.green.pixel); // XSetForeground(x11_global.dpy, gc, whiteColor); @@ -528,6 +534,8 @@ int graphics_event_handler(int world_changed) { //should calling draw_screen be if(motionnotify) { XQueryPointer(x11_global.dpy,x11_global.w,&root,&child,&gra_global.rmousex,&gra_global.rmousey,&gra_global.mousex,&gra_global.mousey,&mask); redraw=1; +// global.camera.r.x.d=gra_global.mousey - (HEIGHT/2); +// global.camera.r.y.d=gra_global.mousex - (LEFT/2); } //redraw=1;//meh. if(redraw || world_changed) { |