using width and height with an array.

edited October 2016 in Questions about Code

Hello,

I need a window what is 80% off fullscreen, but now i have to make a array and if i use width and height i still need width=1728 and height=972. but if i use with an height i get verry small vallues.

void settings() {
  size ((int(0.8*displayWidth)), (int(0.8*displayHeight)));
}

int[][] xy={
  { int(1728/10)*1, int((972/7)*1)},
  { int(1728/10)*2, int(972/7)*1}, 
  { int(1728/10)*3, int(972/7)*1}, 
  { int(1728/10)*4, int(972/7)*1}, 
  { int(1728/10)*5, int((972/7)*1)}, 
  { int(1728/10)*6, int((972/7)*1)}, 
  { int(1728/10)*7, int((972/7)*1)}, 
  { int(1728/10)*8, int((972/7)*1)}
};

so you can see i have used 1728 and 972. but do you now how i can fix it?

some extra things i can not work with classes so please don't use that?

thankYOU.

Answers

  • Edit post, Highlight code, press Ctrl-o

  • Thank koogs, id did not now that it works this way

  • Answer ✓

    Both displayWidth & displayHeight don't change w/ size() as both width & height do!

    So you can keep using them in place of literals 1728 & 972! :-bd

  • edited October 2016 Answer ✓

    Ah! In Java when both operands of a division are integral values, any resulting fractional part is removed already! :P No need to use int() or (int) there at all! ;;)

Sign In or Register to comment.