position - On Android, how to draw a Rect like pygame Rect? (x, y, w, h) -
is there way of drawing rect in android in following pattern, instead of "left, top, right, bottom"? problem i'm using random coordinates:
rect e = new rect(random.nextint(300)+20,20,random.nextint(300)+45,70);
and it's hard keep track of first left random position include in right 1 width. in "x, y, w, h", it's easy apply collision test:
if ((((p.left+p.width())>e.left)&&(p.left<(e.left+e.width())))&& (((p.top+p.height())>e.top)&&(p.top<(e.top+e.height())))) { gamescreen = 2; }
just move random numbers outside of constructor rect.
int left = random.nextint(300)+20; int right = left + 20; int top = random.nextint(300)+45; int bottom = top + 70; rect e = new rect(left, top, right, bottom);
Comments
Post a Comment