Creating Multiple Rectangle Objects at Once (Java) -
first off, clicking :) i'm amateur student coder, , i'm creating (horrible) version of pacman. i'm trying create rectangles each of dots on 1000x650 applet screen, can create if statement when packages hit box touches them, disappear.
my problem is, want create class can create rectangles , have 1 if statement, , not 1 each dot rectangle (trying learn efficient :p)
if didn't elaborate enough, i'll wary bring edits based on responses, , thanks!!!
(edit 1: fixed run on sentence xd)
if need fill rectangles on both x , y (matrix), need nested loops. let's consider want 5 * 5 rectangle every 100 pixels in width 50 pixels spacing in height:
for(int x = 0;x<1000;x+= 100) { for(int y=0;y<650; y+= 50) { drawrectangle(x, y, 5, 5); // considering drawrectangle(x, y, width, height) } }
Comments
Post a Comment