• R/O
  • SSH
  • HTTPS

simyukkuri: 提交


Commit MetaInfo

修订版255 (tree)
时间2015-09-03 20:26:35
作者mimisuke

Log Message

Modified the behavior of bleeding pool.

更改概述

差异

--- branches/test/GarbageChute.java (revision 254)
+++ branches/test/GarbageChute.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218 import java.io.IOException;
319 import javax.imageio.ImageIO;
@@ -63,6 +79,9 @@
6379
6480 @Override
6581 public int getPrice(Price priceType) {
82+ if (priceType == Price.SELLING) {
83+ return value / 2;
84+ }
6685 return value;
6786 }
6887
--- branches/test/MachinePress.java (revision 254)
+++ branches/test/MachinePress.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218 import java.io.IOException;
319 import javax.imageio.ImageIO;
@@ -68,6 +84,9 @@
6884
6985 @Override
7086 public int getPrice(Price priceType) {
87+ if (priceType == Price.SELLING) {
88+ return value / 2;
89+ }
7190 return value;
7291 }
7392
--- branches/test/Body.java (revision 254)
+++ branches/test/Body.java (revision 255)
@@ -82,6 +82,7 @@
8282 private int EYESIGHT = Terrarium.MAX_X * Terrarium.MAX_Y;
8383 private int STRENGTH[] = {0, 100*12, 100*24*2};
8484 private int INCUBATIONPERIOD = 100*12;
85+ private int MAXBABIES = 10;
8586
8687 // individual state variables for each Yukkuri.
8788 private int destX = -1, destY = -1; //destination
@@ -99,7 +100,7 @@
99100 private boolean hasAccessory = true; //true if having accessory
100101 private boolean hasPants = false; //true if having pants
101102 private boolean hasBaby = false; //having baby or not
102- private ArrayList<Integer> babyTypes = new ArrayList<Integer>();
103+ private ArrayList<Body> babyList = new ArrayList<Body>();
103104 private boolean dead = false; //dead of alive
104105 private boolean crashed = false;
105106 private boolean exciting = false; //want to sukkiri or not
@@ -365,12 +366,11 @@
365366 return Damage.NONE;
366367 }
367368
368- private Pain checkPainState()
369- {
370- if ( hasNearMaxNumBabies() ){
369+ private Pain checkPainState() {
370+ if (hasNearMaxNumBabies()) {
371371 return Pain.VERY;
372372 }
373- if ( hasManyBabies() ){
373+ if (hasManyBabies()) {
374374 return Pain.SOME;
375375 }
376376 return Pain.NONE;
@@ -378,7 +378,7 @@
378378
379379 private void checkHungry() {
380380 if (exciting || hasBaby) {
381- hungry += TICK*(babyTypes.size() + (exciting ? 1 : 0));
381+ hungry += TICK*(babyList.size() + (exciting ? 1 : 0));
382382 } else {
383383 hungry += TICK;
384384 }
@@ -463,9 +463,9 @@
463463
464464 private boolean checkChildbirth() {
465465 boolean cantMove = false;
466- if (hasBaby || !hasBaby && birth) {
466+ if (hasBaby || (!hasBaby && birth)) {
467467 pregnantPeriod += TICK + (pregnantPeriodBoost / 2);
468- if (pregnantPeriod > PREGPERIOD - TICK*100) {
468+ if (pregnantPeriod > PREGPERIOD - TICK * 100) {
469469 if (!birth) {
470470 showBreed();
471471 wakeup();
@@ -475,19 +475,20 @@
475475 pregnantPeriodBoost = 0;
476476 }
477477 if (pregnantPeriod > PREGPERIOD) {
478- // Keep babyType for generating baby.
478+ // Keep babyList for generating babys.
479479 hasBaby = false;
480- if ( babyTypes.size() <= 0 ){
480+ if (babyList.size() == 0) {
481481 birth = false;
482482 pregnantPeriod = 0;
483483 showBreed2();
484- }else{
484+ }
485+ else {
485486 cantMove = true;
486487 }
487488 if (hasPants) {
488489 setDirty(true);
489490 setHappiness(Happiness.VERY_SAD);
490- babyTypes.clear();
491+ babyList.clear();
491492 }
492493 }
493494 }
@@ -569,13 +570,14 @@
569570 }
570571 if (noHungryPeriod > RELAXPERIOD && noDamagePeriod > RELAXPERIOD
571572 && !sleeping && !shitting && !eating
572- && !isSad() && !isVerySad() && !isSick()&&!isFeelPain()) {
573+ && !isSad() && !isVerySad() && !isSick() && !isFeelPain()) {
573574 if (!exciting && !relax) {
574575 int r = 1;
575- int adjust = excitingDiscipline*(isRude() ? 1 : 2);
576+ int adjust = excitingDiscipline * (isRude() ? 1 : 2);
576577 if (superRapist) {
577578 r = rnd.nextInt(1 + adjust);
578- }else if (rapist && isRude()) {
579+ }
580+ else if (rapist && isRude()) {
579581 r = rnd.nextInt(6 + adjust);
580582 }
581583 else if (rapist || isRude()) {
@@ -1178,17 +1180,15 @@
11781180 return type;
11791181 }
11801182
1181- public ArrayList<Integer> getBabyTypes() {
1182- return babyTypes;
1183+ public ArrayList<Body> getBabyList() {
1184+ return babyList;
11831185 }
11841186
1185- public int getBabyTypesDequeue() {
1186- int babyType = -1;
1187- if ( babyTypes.size() > 0 ){
1188- babyType = babyTypes.get(0);
1189- babyTypes.remove(0);
1187+ public Body getBabyListDequeue() {
1188+ if (babyList.size() > 0) {
1189+ return(babyList.remove(0));
11901190 }
1191- return babyType;
1191+ return null;
11921192 }
11931193
11941194 public AgeState getAgeState() {
@@ -1291,7 +1291,7 @@
12911291 }
12921292
12931293 public int getMaxHaveBaby() {
1294- return getDamageLimit()/300;
1294+ return (MAXBABIES / (3 - ageState.ordinal()));
12951295 }
12961296
12971297 public int getType() {
@@ -1350,7 +1350,7 @@
13501350 }
13511351
13521352 public void addBaby(int babyType) {
1353- babyTypes.add(babyType);
1353+ babyList.add(new Body(babyType, 0, 0, 0, AgeState.BABY, null, null));
13541354 hasBaby = true;
13551355 }
13561356
@@ -1559,17 +1559,21 @@
15591559 }
15601560
15611561 public boolean hasBabies() {
1562- return getBabyTypes().size() > 0;
1562+ return (babyList.size() > 0);
15631563 }
1564-
1564+
15651565 public boolean hasManyBabies() {
1566- return (getBabyTypes().size() > getMaxHaveBaby()/2 );
1566+ return (babyList.size() > getMaxHaveBaby() / 2);
15671567 }
15681568
15691569 public boolean hasNearMaxNumBabies() {
1570- return (getBabyTypes().size() > getMaxHaveBaby()/5*4 );
1571- }
1570+ return (babyList.size() > getMaxHaveBaby() * 4 / 5);
1571+ }
15721572
1573+ public boolean hasMaxNumBabies() {
1574+ return (babyList.size() > getMaxHaveBaby());
1575+ }
1576+
15731577 public boolean wantToShit() {
15741578 int step = (checkHungryState() == Hunger.NONE ? TICK*2 : TICK);
15751579 int adjust = 100*(isRude() ? 1 : 2)*shittingDiscipline;
@@ -1647,7 +1651,7 @@
16471651 partner = p;
16481652 p.partner = this;
16491653 }
1650- p.babyTypes.add(decideBabyType(p));
1654+ p.babyList.add(new Body(decideBabyType(p), 0, 0, 0, AgeState.BABY, this, p));
16511655 p.hasBaby = true;
16521656 }
16531657
@@ -2026,7 +2030,7 @@
20262030 }
20272031
20282032 public void rapidPregnantPeriod(){
2029- if (babyTypes.size() != 0 ){
2033+ if (babyList.size() != 0 ){
20302034 pregnantPeriodBoost += TICK;
20312035 }
20322036 }
@@ -2103,10 +2107,10 @@
21032107
21042108 // calling every tick
21052109 @Override
2106- public Obj.Event clockTick() {
2110+ public Event clockTick() {
21072111 // if removed, remove body
21082112 if (removed) {
2109- return Obj.Event.REMOVED;
2113+ return Event.REMOVED;
21102114 }
21112115
21122116 // if partner and parents are removed, clean relationship.
@@ -2116,7 +2120,7 @@
21162120 if (dead) {
21172121 moveBody(true); // for falling the body
21182122 checkMessage();
2119- return Obj.Event.DEAD;
2123+ return Event.DEAD;
21202124 }
21212125
21222126 Event retval = Event.DONOTHING;
@@ -2128,7 +2132,7 @@
21282132 moveBody(true); // for falling the body
21292133 checkMessage();
21302134 if (dead){
2131- return Obj.Event.DEAD;
2135+ return Event.DEAD;
21322136 }
21332137 }
21342138 ageState = checkAgeState();
@@ -2149,7 +2153,7 @@
21492153 }
21502154 if (oldShit != 0 && shit == 0) {
21512155 if (!hasPants()) {
2152- retval = Obj.Event.DOSHIT;
2156+ retval = Event.DOSHIT;
21532157 }
21542158 }
21552159
@@ -2158,20 +2162,26 @@
21582162 if (checkChildbirth()) {
21592163 dontMove = true;
21602164 }
2161- if (oldHasBaby == true && hasBaby == false || hasBaby == false && birth == true) {
2165+ if ((oldHasBaby && !hasBaby) || (!hasBaby && birth)) {
21622166 if (!hasPants()) {
2163- retval = Obj.Event.BIRTHBABY;
2167+ retval = Event.BIRTHBABY;
21642168 }
21652169 }
2166-
2167- if ( getBabyTypes().size() > getMaxHaveBaby() ){
2168- toDead();
2169- moveBody(true); // for falling the body
2170- checkMessage();
2171- if (dead){
2172- bodyBurst();
2173- return Obj.Event.DEAD;
2170+ if (babyList.size() > getMaxHaveBaby()) {
2171+ for (Body baby: babyList) {
2172+ baby.toDead();
21742173 }
2174+ strike(HAMMER * 2);
2175+ angry = false;
2176+ scare = false;
2177+ setDirty(true);
2178+ setHappiness(Happiness.VERY_SAD);
2179+ if (!hasPants()) {
2180+ return Event.STILLBIRTH;
2181+ }
2182+ else {
2183+ babyList.clear();
2184+ }
21752185 }
21762186
21772187 // check sleep
@@ -2285,6 +2295,7 @@
22852295 DAMAGELIMIT[AgeState.BABY.ordinal()] *= factor;
22862296 ROBUSTNESS *= factor;
22872297 DIRTYPERIOD *= factor;
2298+ MAXBABIES *= factor;
22882299
22892300 factor = Math.random() + InitLoader.getStrength(type);
22902301 //System.out.println("strength:"+factor);
--- branches/test/Toilet.java (revision 254)
+++ branches/test/Toilet.java (revision 255)
@@ -45,6 +45,9 @@
4545
4646 @Override
4747 public int getPrice(Price priceType) {
48+ if (priceType == Price.SELLING) {
49+ return value / 2;
50+ }
4851 return value;
4952 }
5053
--- branches/test/OrangePool.java (revision 254)
+++ branches/test/OrangePool.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218 import java.io.IOException;
319 import javax.imageio.ImageIO;
@@ -74,6 +90,9 @@
7490
7591 @Override
7692 public int getPrice(Price priceType) {
93+ if (priceType == Price.SELLING) {
94+ return value[type] / 2;
95+ }
7796 return value[type];
7897 }
7998
--- branches/test/FoodMaker.java (revision 254)
+++ branches/test/FoodMaker.java (revision 255)
@@ -191,6 +191,9 @@
191191
192192 @Override
193193 public int getPrice(Price priceType) {
194+ if (priceType == Price.SELLING) {
195+ return value / 2;
196+ }
194197 return value;
195198 }
196199
--- branches/test/ObjEX.java (revision 254)
+++ branches/test/ObjEX.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218
319 public class ObjEX extends Obj implements java.io.Serializable {
--- branches/test/BreedingPool.java (revision 254)
+++ branches/test/BreedingPool.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218 import java.io.IOException;
319 import javax.imageio.ImageIO;
@@ -40,14 +56,16 @@
4056 public void objHitProcess(Obj o) {
4157 if (o.objType == Obj.Type.YUKKURI) {
4258 Body p = (Body) o;
43- if (p.isDead() == false && (int) age % ((highDensity == true) ? 4 : 10) == 0) {
59+ if (!p.isDead() && (int) age % ((highDensity == true) ? 4 : 10) == 0) {
4460 int babyType;
45- babyType = p.getType();
46- if ((p.getMutationType() != -1) && rnd.nextBoolean()) {
61+ if (p.isSick() || p.isDamaged()) {
62+ babyType = InitLoader.getIdiotType();
63+ }
64+ else if ((p.getMutationType() != -1) && rnd.nextBoolean()) {
4765 babyType = p.getMutationType();
4866 }
49- if ((p.isSick() || p.isSick()) || p.isDamaged() || p.isDamaged()) {
50- babyType = InitLoader.getIdiotType();
67+ else {
68+ babyType = p.getType();
5169 }
5270 p.addBaby(babyType);
5371 if (rapidGrowth == true) {
@@ -61,7 +79,10 @@
6179
6280 @Override
6381 public int getPrice(Price priceType) {
64- return value[type];
82+ if (priceType == Price.SELLING) {
83+ return value[type] / 2;
84+ }
85+ return value[type]; // BUYING
6586 }
6687
6788 @Override
--- branches/test/ProductChute.java (revision 254)
+++ branches/test/ProductChute.java (revision 255)
@@ -82,6 +82,9 @@
8282
8383 @Override
8484 public int getPrice(Price priceType) {
85+ if (priceType == Price.SELLING) {
86+ return value / 2;
87+ }
8588 return value;
8689 }
8790
--- branches/test/Terrarium.java (revision 254)
+++ branches/test/Terrarium.java (revision 255)
@@ -709,19 +709,21 @@
709709 }
710710 return ret;
711711 }
712-
713712
714- private void addBaby(int x, int y, int z, int type, Body p1, Body p2) {
715- Body b = makeBody(x, y, z + 1, type, Body.AgeState.BABY, p1, p2);
716- b.kick(0,5,-2);
717- babyList.add(b);
718-
713+ private void addBaby(int x, int y, int z, Body baby) {
714+ baby.setX(x);
715+ baby.setY(y);
716+ baby.setZ(z + 1);
717+ baby.kick(0, 5, -2);
718+ babyList.add(baby);
719719 }
720720
721- private void addBaby(int x, int y, int z, int vx, int vy, int vz, int type, Body p1, Body p2) {
722- Body b = makeBody(x, y, z + 1, type, Body.AgeState.BABY, p1, p2);
723- b.kick(vx,vy,vz);
724- babyList.add(b);
721+ private void addBaby(int x, int y, int z, int vx, int vy, int vz, Body baby) {
722+ baby.setX(x);
723+ baby.setY(y);
724+ baby.setZ(z + 1);
725+ baby.kick(vx,vy,vz);
726+ babyList.add(baby);
725727
726728 }
727729
@@ -938,22 +940,21 @@
938940 ret = b.clockTick();
939941 switch (ret) {
940942 case DEAD:
941- if (b.getBabyTypes().size() >= b.getMaxHaveBaby()/120) {
942- int numOfBaby = b.getBabyTypes().size();
943- for ( int babyTypes:b.getBabyTypes()) {
944- addBaby(b.getX(), b.getY(), b.getZ()+b.getSize()/20, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8-2, babyTypes, b, b.getPartner());
943+ continue;
944+ case STILLBIRTH:
945+ if (b.getBabyList().size() > 0) {
946+ int numOfBaby = b.getBabyList().size();
947+ for (Body baby:b.getBabyList()) {
948+ addBaby(b.getX(), b.getY(), b.getZ()+b.getSize()/20, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8, rnd.nextInt(numOfBaby/4+1)-numOfBaby/8-2, baby);
945949 }
946- b.getBabyTypes().clear();
947- if ( b.isCrashed() == false ) {
948- b.strikeByPress();
949- }
950+ b.getBabyList().clear();
950951 }
951952 continue;
952953 case BIRTHBABY:
953954 if ( b.age % 10 == 0 ){
954- int babyType = b.getBabyTypesDequeue();
955- if ( babyType != -1 ){
956- addBaby(b.getX(), b.getY(), b.getZ()+b.getSize()/15, babyType, b, b.getPartner());
955+ Body baby = b.getBabyListDequeue();
956+ if (baby != null){
957+ addBaby(b.getX(), b.getY(), b.getZ()+b.getSize()/15, baby);
957958 }
958959 }
959960 break;
--- branches/test/Obj.java (revision 254)
+++ branches/test/Obj.java (revision 255)
@@ -25,7 +25,7 @@
2525 }
2626
2727 public enum Event {
28- DONOTHING, BIRTHBABY, DOSHIT, DEAD, REMOVED
28+ DONOTHING, BIRTHBABY, DOSHIT, DEAD, REMOVED, STILLBIRTH
2929 }
3030
3131 public enum Price {
@@ -142,8 +142,8 @@
142142 return objType;
143143 }
144144
145- public int getPrice(Price type) {
146- if (type == Price.SELLING) {
145+ public int getPrice(Price priceType) {
146+ if (priceType == Price.SELLING) {
147147 return value / 2;
148148 }
149149 return value; // BUYING
--- branches/test/Toy.java (revision 254)
+++ branches/test/Toy.java (revision 255)
@@ -78,6 +78,9 @@
7878
7979 @Override
8080 public int getPrice(Price priceType) {
81+ if (priceType == Price.SELLING) {
82+ return value / 2;
83+ }
8184 return value;
8285 }
8386
--- branches/test/Beltconveyor.java (revision 254)
+++ branches/test/Beltconveyor.java (revision 255)
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
117 import java.awt.Image;
218 import java.io.IOException;
319 import javax.imageio.ImageIO;
@@ -86,7 +102,10 @@
86102
87103 @Override
88104 public int getPrice(Price priceType) {
89- return value;
105+ if (priceType == Price.SELLING) {
106+ return value / 2;
107+ }
108+ return value; // BUYING
90109 }
91110
92111 @Override
--- branches/test/SimYukkuri.java (revision 254)
+++ branches/test/SimYukkuri.java (revision 255)
@@ -409,10 +409,8 @@
409409 case YUKKURI:
410410 {
411411 Body b = (Body)o;
412- int offsetX = (Body.MAXSIZE - b.getSize())/2;
413- int offsetY = (Body.MAXSIZE - b.getSize());
414- int dx = e.getX() - (Translate.transX(b.getX(), b.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
415- int dy = e.getY() - (Translate.transY(b.getX(), b.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY) + b.getZ()*58/10;
412+ int dx = e.getX() - Translate.transX(b.getX(), b.getY(), b.getSize(), w);
413+ int dy = e.getY() - Translate.transY(b.getX(), b.getY(), b.getSize(), h) + b.getZ() * h / Terrarium.MAX_Z;
416414 if (dx >= 0 && dx <= b.getSize() && dy >= 0 && dy <= b.getSize()) {
417415 found = b;
418416 oX = dx;
@@ -423,10 +421,8 @@
423421 case SHIT:
424422 {
425423 Shit s = (Shit)o;
426- int offsetX = (Body.MAXSIZE - s.getSize())/2;
427- int offsetY = (Body.MAXSIZE - s.getSize());
428- int dx = e.getX() - (Translate.transX(s.getX(), s.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
429- int dy = e.getY() - (Translate.transY(s.getX(), s.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY) + s.getZ()*58/10;
424+ int dx = e.getX() - Translate.transX(s.getX(), s.getY(), s.getSize(), w);
425+ int dy = e.getY() - Translate.transY(s.getX(), s.getY(), s.getSize(), h) + s.getZ() * h / Terrarium.MAX_Z;
430426 if (dx >= 0 && dx <= s.getSize() && dy >= 0 && dy <= s.getSize()) {
431427 found = s;
432428 oX = dx;
@@ -437,10 +433,8 @@
437433 case FOOD:
438434 {
439435 Food f = (Food)o;
440- int offsetX = (Body.MAXSIZE - f.getSize())/2;
441- int offsetY = (Body.MAXSIZE - f.getSize()/2);
442- int dx = e.getX() - (Translate.transX(f.getX(), f.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
443- int dy = e.getY() - (Translate.transY(f.getX(), f.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY) + f.getZ()*58/10;
436+ int dx = e.getX() - Translate.transX(f.getX(), f.getY(), f.getSize(), w);
437+ int dy = e.getY() - Translate.transY(f.getX(), f.getY(), f.getSize()/2, h) + f.getZ() * h / Terrarium.MAX_Z;
444438 if (dx >= 0 && dx <= f.getSize() && dy >= 0 && dy <= f.getSize()/2) {
445439 found = f;
446440 oX = dx;
@@ -451,10 +445,8 @@
451445 case TOY:
452446 {
453447 Toy t = (Toy)o;
454- int offsetX = (Body.MAXSIZE - t.getSize())/2;
455- int offsetY = (Body.MAXSIZE - t.getSize());
456- int dx = e.getX() - (Translate.transX(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
457- int dy = e.getY() - (Translate.transY(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY) + t.getZ()*58/10;
448+ int dx = e.getX() - Translate.transX(t.getX(), t.getY(), t.getSize(), w);
449+ int dy = e.getY() - Translate.transY(t.getX(), t.getY(), t.getSize(), h) + t.getZ() * h / Terrarium.MAX_Z;
458450 if (dx >= 0 && dx <= t.getSize() && dy >= 0 && dy <= t.getSize()) {
459451 found = t;
460452 oX = dx;
@@ -469,10 +461,8 @@
469461 if (fo.getZ() != 0) {
470462 continue;
471463 }
472- int offsetX = (Body.MAXSIZE - fo.getSize())/2;
473- int offsetY = (Body.MAXSIZE - fo.getSize()/2)-128;
474- int dx = e.getX() - (Translate.transX(fo.getX(), fo.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
475- int dy = e.getY() - (Translate.transY(fo.getX(), fo.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY) + fo.getZ()*58/10;
464+ int dx = e.getX() - Translate.transX(fo.getX(), fo.getY(), fo.getSize(), w);
465+ int dy = e.getY() - Translate.transY(fo.getX(), fo.getY(), fo.getSize()/2, h) + 128 + fo.getZ() * h / Terrarium.MAX_Z;
476466 if (dx >= 0 && dx <= fo.getSize() && dy >= 0 && dy <= fo.getSize()) {
477467 found = fo;
478468 oX = dx;
@@ -486,12 +476,10 @@
486476 }
487477 }
488478 if (found == null) { // Toilet has lower priority.
489- for (Toilet t:Terrarium.toiletList) {
490- int offsetX = (Body.MAXSIZE - t.getSize())/2;
491- int offsetY = (Body.MAXSIZE - t.getSize()*2/3);
492- int dx = e.getX() - (Translate.transX(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
493- int dy = e.getY() - (Translate.transY(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY);
494- if (dx >= 0 && dx <= t.getSize() && dy >= 0 && dy <= t.getSize()*2/3) {
479+ for (Toilet t : Terrarium.toiletList) {
480+ int dx = e.getX() - Translate.transX(t.getX(), t.getY(), t.getSize(), w);
481+ int dy = e.getY() - Translate.transY(t.getX(), t.getY(), t.getSize() * 2 / 3, h);
482+ if (dx >= 0 && dx <= t.getSize() && dy >= 0 && dy <= t.getSize() * 2 / 3) {
495483 found = t;
496484 oX = dx;
497485 oY = dy;
@@ -499,14 +487,12 @@
499487 }
500488 }
501489 if (found == null) {// platform has lowest priority.
502- List <ObjEX>platformList = Terrarium.getPlatformList();
490+ List<ObjEX> platformList = Terrarium.getPlatformList();
503491 for (Iterator<ObjEX> i = platformList.iterator(); i.hasNext();) {
504492 ObjEX oex = (ObjEX)i.next();
505- int offsetX = (Body.MAXSIZE - oex.getSize())/2;
506- int offsetY = (Body.MAXSIZE - oex.getSize()/2);
507- int dx = e.getX() - (Translate.transX(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX);
508- int dy = e.getY() - (Translate.transY(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY);
509- if (dx >= 0 && dx <= oex.getSize()*9/4/2 && dy >= 0 && dy <= oex.getSize()*3/2/2) {
493+ int dx = e.getX() - Translate.transX(oex.getX(), oex.getY(), oex.getSize(), w);
494+ int dy = e.getY() - Translate.transY(oex.getX(), oex.getY(), oex.getSize() / 2, h);
495+ if (dx >= 0 && dx <= oex.getSize() * 9 / 4 / 2 && dy >= 0 && dy <= oex.getSize() * 3 / 2 / 2) {
510496 found = oex;
511497 oX = dx;
512498 oY = dy;
@@ -523,11 +509,8 @@
523509 synchronized(lock) {
524510 if ((s1.getSelectedIndex() == BARRIER) && (s2.getSelectedIndex() == DEL)) {
525511 Dimension size = mypane.getSize();
526- int w = size.width, h = size.height;
527- int X = (e.getX() - Body.MAXSIZE/2)*Terrarium.MAX_X/(w-Body.MAXSIZE);
528- int Y = (e.getY() - Body.MAXSIZE)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
529- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
530- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
512+ int x = Translate.invX(e.getX(), e.getY(), 0, size.width, size.height);
513+ int y = Translate.invY(e.getX(), e.getY(), 0, size.width, size.height);
531514 Barrier found = Terrarium.getBarrier(x, y, 10);
532515 if (found != null) {
533516 Terrarium.clearBarrier(found);
@@ -619,12 +602,8 @@
619602 int w = size.width, h = size.height;
620603 switch (s1.getSelectedIndex()) {
621604 case FOOD: {
622- int offsetX = (Body.MAXSIZE - Food.getSizeS())/2;
623- int offsetY = (Body.MAXSIZE - Food.getSizeS()/2);
624- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
625- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
626- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
627- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
605+ int x = Translate.invX(e.getX(), e.getY(), Food.getSizeS(), w, h);
606+ int y = Translate.invY(e.getX(), e.getY(), Food.getSizeS() / 2, w, h);
628607 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
629608 Food.type foodType;
630609 switch (s2.getSelectedIndex()) {
@@ -656,12 +635,8 @@
656635 }
657636 break;
658637 case TOILET: {
659- int offsetX = (Body.MAXSIZE - Toilet.getSizeS())/2;
660- int offsetY = (Body.MAXSIZE - Toilet.getSizeS()*2/3);
661- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
662- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
663- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
664- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
638+ int x = Translate.invX(e.getX(), e.getY(), Toilet.getSizeS(), w, h);
639+ int y = Translate.invY(e.getX(), e.getY(), Toilet.getSizeS() * 2 / 3, w, h);
665640 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
666641 mypane.terrarium.addToilet(x, y);
667642 }
@@ -668,12 +643,8 @@
668643 }
669644 break;
670645 case TOYS: {
671- int offsetX = (Body.MAXSIZE - Toy.getSizeS())/2;
672- int offsetY = (Body.MAXSIZE - Toy.getSizeS());
673- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
674- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
675- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
676- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
646+ int x = Translate.invX(e.getX(), e.getY(), Toy.getSizeS(), w, h);
647+ int y = Translate.invY(e.getX(), e.getY(), Toy.getSizeS(), w, h);
677648 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
678649 mypane.terrarium.addToy(x, y);
679650 }
@@ -681,12 +652,8 @@
681652 break;
682653
683654 case BELTCONVEYOR: {
684- int offsetX = (Body.MAXSIZE - Beltconveyor.getSizeS())/2;
685- int offsetY = (Body.MAXSIZE - Beltconveyor.getSizeS()/2);
686- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
687- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
688- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
689- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
655+ int x = Translate.invX(e.getX(), e.getY(), Beltconveyor.getSizeS(), w, h);
656+ int y = Translate.invY(e.getX(), e.getY(), Beltconveyor.getSizeS() / 2, w, h);
690657 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
691658 ObjEX.Direction dir;
692659 switch (s2.getSelectedIndex()) {
@@ -710,28 +677,24 @@
710677 break;
711678
712679 case BREEDINGPOOL: {
713- int offsetX = (Body.MAXSIZE - BreedingPool.getSizeS())/2;
714- int offsetY = (Body.MAXSIZE - BreedingPool.getSizeS()/2);
715- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
716- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
717- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
718- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
680+ int x = Translate.invX(e.getX(), e.getY(), BreedingPool.getSizeS(), w, h);
681+ int y = Translate.invY(e.getX(), e.getY(), BreedingPool.getSizeS() / 2, w, h);
719682 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
720683 ObjEX.Direction dir;
721684 switch (s2.getSelectedIndex()) {
722- case BACK:
723- default:
724- dir = ObjEX.Direction.BACK;
725- break;
726- case THISSIDE:
727- dir = ObjEX.Direction.THISSIDE;
728- break;
729- case RIGHT:
730- dir = ObjEX.Direction.RIGHT;
731- break;
732- case LEFT:
733- dir = ObjEX.Direction.LEFT;
734- break;
685+ case BACK:
686+ default:
687+ dir = ObjEX.Direction.BACK;
688+ break;
689+ case THISSIDE:
690+ dir = ObjEX.Direction.THISSIDE;
691+ break;
692+ case RIGHT:
693+ dir = ObjEX.Direction.RIGHT;
694+ break;
695+ case LEFT:
696+ dir = ObjEX.Direction.LEFT;
697+ break;
735698 }
736699 mypane.terrarium.addObjEX(BREEDINGPOOL, x, y, dir);
737700 }
@@ -738,13 +701,9 @@
738701 }
739702 break;
740703
741- case GARBAGECHUTE: {
742- int offsetX = (Body.MAXSIZE - GarbageChute.getSizeS())/2;
743- int offsetY = (Body.MAXSIZE - GarbageChute.getSizeS()/2);
744- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
745- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
746- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
747- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
704+ case GARBAGECHUTE: {
705+ int x = Translate.invX(e.getX(), e.getY(), GarbageChute.getSizeS(), w, h);
706+ int y = Translate.invY(e.getX(), e.getY(), GarbageChute.getSizeS() / 2, w, h);
748707 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
749708 mypane.terrarium.addObjEX(GARBAGECHUTE, x, y, ObjEX.Direction.BACK);
750709 }
@@ -752,12 +711,8 @@
752711 break;
753712
754713 case MACHINEPRESS: {
755- int offsetX = (Body.MAXSIZE - MachinePress.getSizeS())/2;
756- int offsetY = (Body.MAXSIZE - MachinePress.getSizeS()/2);
757- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
758- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
759- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
760- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
714+ int x = Translate.invX(e.getX(), e.getY(), MachinePress.getSizeS(), w, h);
715+ int y = Translate.invY(e.getX(), e.getY(), MachinePress.getSizeS() / 2, w, h);
761716 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
762717 mypane.terrarium.addObjEX(MACHINEPRESS, x, y, ObjEX.Direction.BACK);
763718 }
@@ -765,12 +720,8 @@
765720 break;
766721
767722 case FOODMAKER: {
768- int offsetX = (Body.MAXSIZE - GarbageChute.getSizeS())/2;
769- int offsetY = (Body.MAXSIZE - GarbageChute.getSizeS()/2);
770- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
771- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
772- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
773- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
723+ int x = Translate.invX(e.getX(), e.getY(), FoodMaker.getSizeS(), w, h);
724+ int y = Translate.invY(e.getX(), e.getY(), FoodMaker.getSizeS() / 2, w, h);
774725 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
775726 mypane.terrarium.addObjEX(FOODMAKER, x, y, ObjEX.Direction.BACK);
776727 }
@@ -777,13 +728,9 @@
777728 }
778729 break;
779730
780- case ORANGEPOOL: {
781- int offsetX = (Body.MAXSIZE - GarbageChute.getSizeS())/2;
782- int offsetY = (Body.MAXSIZE - GarbageChute.getSizeS()/2);
783- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
784- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
785- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
786- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
731+ case ORANGEPOOL: {
732+ int x = Translate.invX(e.getX(), e.getY(), OrangePool.getSizeS(), w, h);
733+ int y = Translate.invY(e.getX(), e.getY(), OrangePool.getSizeS() / 2, w, h);
787734 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
788735 ObjEX.Direction dir;
789736 switch (s2.getSelectedIndex()) {
@@ -807,12 +754,8 @@
807754 break;
808755
809756 case PRODUCTCHUTE: {
810- int offsetX = (Body.MAXSIZE - GarbageChute.getSizeS())/2;
811- int offsetY = (Body.MAXSIZE - GarbageChute.getSizeS()/2);
812- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
813- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
814- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
815- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
757+ int x = Translate.invX(e.getX(), e.getY(), ProductChute.getSizeS(), w, h);
758+ int y = Translate.invY(e.getX(), e.getY(), ProductChute.getSizeS() / 2, w, h);
816759 if (x >= 0 && x <= Terrarium.MAX_X && y >= 0 && y <= Terrarium.MAX_Y) {
817760 mypane.terrarium.addObjEX(PRODUCTCHUTE, x, y, ObjEX.Direction.BACK);
818761 }
@@ -831,11 +774,8 @@
831774 if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
832775 if ((s1.getSelectedIndex() == BARRIER) && (s2.getSelectedIndex() == SET)) {
833776 Dimension size = mypane.getSize();
834- int w = size.width, h = size.height;
835- int X = (e.getX() - Body.MAXSIZE/2)*Terrarium.MAX_X/(w-Body.MAXSIZE);
836- int Y = (e.getY() - Body.MAXSIZE)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
837- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
838- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
777+ int x = Translate.invX(e.getX(), e.getY(), 0, size.width, size.height);
778+ int y = Translate.invY(e.getX(), e.getY(), 0, size.width, size.height);
839779 barrierSX = Math.max(0, Math.min(x, Terrarium.MAX_X));
840780 barrierSY = Math.max(0, Math.min(y, Terrarium.MAX_Y));
841781 barrierEX = barrierSX;
@@ -854,7 +794,7 @@
854794 if (grabbedObj != null) {
855795 // yukkuri has been grabbed.
856796 startY = e.getY();
857- startZ = e.getY() + grabbedObj.getZ()*58/10;
797+ startZ = e.getY() + grabbedObj.getZ() * mypane.getSize().height / Terrarium.MAX_Z;
858798 grabbedObj.grab();
859799 if (grabbedObj instanceof Body) {
860800 showStatus((Body)grabbedObj);
@@ -870,12 +810,9 @@
870810 }
871811 if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
872812 if ((s1.getSelectedIndex() == BARRIER) && (s2.getSelectedIndex() == SET)) {
873- Dimension size = mypane.getSize();
874- int w = size.width, h = size.height;
875- int X = (e.getX() - Body.MAXSIZE/2)*Terrarium.MAX_X/(w-Body.MAXSIZE);
876- int Y = (e.getY() - Body.MAXSIZE)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
877- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
878- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
813+ Dimension size = mypane.getSize();
814+ int x = Translate.invX(e.getX(), e.getY(), 0, size.width, size.height);
815+ int y = Translate.invY(e.getX(), e.getY(), 0, size.width, size.height);
879816 barrierEX = Math.max(0, Math.min(x, Terrarium.MAX_X));
880817 barrierEY = Math.max(0, Math.min(y, Terrarium.MAX_Y));
881818 if ((barrierSX != barrierEX) || (barrierSY != barrierEY)) {
@@ -890,7 +827,7 @@
890827 }
891828 if (grabbedObj != null) {
892829 if ( grabbedObj.getZ() > 0 ){
893- grabbedObj.kick(SimYukkuri.mouseVX/15, 0, SimYukkuri.mouseVY/20);
830+ grabbedObj.kick(SimYukkuri.mouseVX / 15, 0, SimYukkuri.mouseVY / 20);
894831 }
895832 grabbedObj.release();
896833 grabbedObj = null;
@@ -905,12 +842,9 @@
905842 synchronized(lock) {
906843 if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) {
907844 if ((s1.getSelectedIndex() == BARRIER) && (s2.getSelectedIndex() == SET)) {
908- Dimension size = mypane.getSize();
909- int w = size.width, h = size.height;
910- int X = (e.getX() - Body.MAXSIZE/2)*Terrarium.MAX_X/(w-Body.MAXSIZE);
911- int Y = (e.getY() - Body.MAXSIZE)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
912- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
913- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
845+ Dimension size = mypane.getSize();
846+ int x = Translate.invX(e.getX(), e.getY(), 0, size.width, size.height);
847+ int y = Translate.invY(e.getX(), e.getY(), 0, size.width, size.height);
914848 barrierEX = Math.max(0, Math.min(x, Terrarium.MAX_X));
915849 barrierEY = Math.max(0, Math.min(y, Terrarium.MAX_Y));
916850 return;
@@ -935,46 +869,46 @@
935869 switch (grabbedObj.objType) {
936870 case YUKKURI: {
937871 Body b = (Body)grabbedObj;
938- offsetX = (Body.MAXSIZE - b.getSize())/2;
872+ offsetX = (Body.MAXSIZE - b.getSize()) / 2;
939873 offsetY = (Body.MAXSIZE - b.getSize());
940874 break;
941875 }
942876 case SHIT: {
943877 Shit s = (Shit)grabbedObj;
944- offsetX = (Body.MAXSIZE - s.getSize())/2;
878+ offsetX = (Body.MAXSIZE - s.getSize()) / 2;
945879 offsetY = (Body.MAXSIZE - s.getSize());
946880 break;
947881 }
948882 case FOOD: {
949883 Food f = (Food)grabbedObj;
950- offsetX = (Body.MAXSIZE - f.getSize())/2;
951- offsetY = (Body.MAXSIZE - f.getSize()/2);
884+ offsetX = (Body.MAXSIZE - f.getSize()) / 2;
885+ offsetY = (Body.MAXSIZE - f.getSize() / 2);
952886 break;
953887 }
954888 case TOILET: {
955889 Toilet t = (Toilet)grabbedObj;
956- offsetX = (Body.MAXSIZE - t.getSize())/2;
957- offsetY = (Body.MAXSIZE - t.getSize()*2/3);
890+ offsetX = (Body.MAXSIZE - t.getSize()) / 2;
891+ offsetY = (Body.MAXSIZE - t.getSize() * 2 / 3);
958892 break;
959893 }
960894 case TOY: {
961895 Toy t = (Toy)grabbedObj;
962- offsetX = (Body.MAXSIZE - t.getSize())/2;
896+ offsetX = (Body.MAXSIZE - t.getSize()) / 2;
963897 offsetY = (Body.MAXSIZE - t.getSize());
964898 break;
965899 }
966900
967- case PLATFORM:{
901+ case PLATFORM: {
968902 ObjEX p = (ObjEX)grabbedObj;
969- offsetX = (Body.MAXSIZE - p.getSize())/2;
970- offsetY = (Body.MAXSIZE - p.getSize()/2);
903+ offsetX = (Body.MAXSIZE - p.getSize()) / 2;
904+ offsetY = (Body.MAXSIZE - p.getSize() / 2);
971905 break;
972906 }
973-
974- case FIX_OBJECT:{
907+
908+ case FIX_OBJECT: {
975909 ObjEX p = (ObjEX)grabbedObj;
976- offsetX = (Body.MAXSIZE - p.getSize())/2;
977- offsetY = (Body.MAXSIZE - p.getSize()/2)-128;
910+ offsetX = (Body.MAXSIZE - p.getSize()) / 2;
911+ offsetY = (Body.MAXSIZE - p.getSize() / 2) - 128;
978912 break;
979913 }
980914
@@ -983,22 +917,22 @@
983917 }
984918
985919 if ((button == 1) && (s1.getSelectedIndex() == PICKUP)) {
986- int X = (e.getX() - oX - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
987- int Y = (startY - oY - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
988- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
920+ int X = (e.getX() - oX - offsetX) * Terrarium.MAX_X / (w - Body.MAXSIZE);
921+ int Y = (startY - oY - offsetY) * Terrarium.MAX_Y / (h - Body.MAXSIZE);
922+ int x = Translate.invX(X, Y);
989923 grabbedObj.setX(x);
990924 if (startZ - e.getY() > 0) {
991925 altitude = startZ - e.getY();
992- grabbedObj.setZ((startZ - e.getY())*Terrarium.MAX_Z/h);
926+ grabbedObj.setZ((startZ - e.getY()) * Terrarium.MAX_Z / h);
993927 }
994928 }
995929 else if (button == 2) {
996- int X = (e.getX() - oX - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
997- int Y = (e.getY() - oY - offsetY + altitude)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
998- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
999- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y) + grabbedObj.getZ()*58/10;
930+ int X = (e.getX() - oX - offsetX) * Terrarium.MAX_X / (w - Body.MAXSIZE);
931+ int Y = (e.getY() - oY - offsetY + altitude) * Terrarium.MAX_Y / (h - Body.MAXSIZE);
932+ int x = Translate.invX(X, Y);
933+ int y = Translate.invY(X, Y) + grabbedObj.getZ() * Terrarium.MAX_Z / h;
1000934 grabbedObj.setX(x);
1001- grabbedObj.setY(y);
935+ grabbedObj.setY(y);
1002936 }
1003937 }
1004938 mouseNewX = e.getX();
@@ -1015,12 +949,8 @@
1015949 Dimension size = mypane.getSize();
1016950 int w = size.width, h = size.height;
1017951 for (Body b:Terrarium.bodyList) {
1018- int offsetX = (Body.MAXSIZE - b.getSize())/2;
1019- int offsetY = (Body.MAXSIZE - b.getSize());
1020- int X = (e.getX() - offsetX)*Terrarium.MAX_X/(w-Body.MAXSIZE);
1021- int Y = (e.getY() - offsetY)*Terrarium.MAX_Y/(h-Body.MAXSIZE);
1022- int x = Translate.invX(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
1023- int y = Translate.invY(X, Y, Terrarium.MAX_X, Terrarium.MAX_Y);
952+ int x = Translate.invX(e.getX(), e.getY(), b.getSize(), w, h);
953+ int y = Translate.invY(e.getX(), e.getY(), b.getSize(), w, h);
1024954 if (b.isAdult()) {
1025955 b.setAngry();
1026956 b.lookTo(x, y);
@@ -1052,10 +982,10 @@
1052982
1053983 }
1054984
1055- public static void checkMouseVel(){
1056- synchronized(lock) {
1057- mouseVX = (mouseNewX - mouseOldX) + mouseVX/3*2;
1058- mouseVY = (mouseNewY - mouseOldY) + mouseVY/3*2;
985+ public static void checkMouseVel() {
986+ synchronized (lock) {
987+ mouseVX = (mouseNewX - mouseOldX) + mouseVX / 3 * 2;
988+ mouseVY = (mouseNewY - mouseOldY) + mouseVY / 3 * 2;
1059989 mouseOldX = mouseNewX;
1060990 mouseOldY = mouseNewY;
1061991 }
@@ -1073,16 +1003,16 @@
10731003
10741004 static final Random rnd = new Random();
10751005 static final int PAUSE = -1, MAX = 1, DECUPLE = 10, QUINTUPLE = 20, NORMAL = 100;
1076- static final int gameSpeed[]={PAUSE, NORMAL, QUINTUPLE, DECUPLE, MAX};
1006+ static final int gameSpeed[] = {PAUSE, NORMAL, QUINTUPLE, DECUPLE, MAX};
10771007
10781008 public void run() {
1079- //load images
1009+ // load images
10801010 String path = InitLoader.getImagePath();
10811011 try {
10821012 ClassLoader loader = this.getClass().getClassLoader();
10831013 // load background image
10841014 backGroundImage = ImageIO.read(loader.getResourceAsStream(path + "back.jpg"));
1085-
1015+
10861016 // load gadget images
10871017 Food.loadImages(loader, path);
10881018 Shit.loadImages(loader, path);
@@ -1099,16 +1029,19 @@
10991029
11001030 // load all body images and dialogues
11011031 Body.loadImages(loader, path);
1102-
1103- } catch (IOException e) {
1032+
1033+ }
1034+ catch (IOException e) {
11041035 JOptionPane.showMessageDialog(this, "File I/O error", SimYukkuri.TITLE, JOptionPane.ERROR_MESSAGE);
11051036 e.printStackTrace();
11061037 System.exit(1);
1107- } catch (IllegalArgumentException e) {
1038+ }
1039+ catch (IllegalArgumentException e) {
11081040 JOptionPane.showMessageDialog(this, "Image or init file not found", SimYukkuri.TITLE, JOptionPane.ERROR_MESSAGE);
11091041 e.printStackTrace();
11101042 System.exit(1);
1111- } catch (NullPointerException e) {
1043+ }
1044+ catch (NullPointerException e) {
11121045 JOptionPane.showMessageDialog(this, "Init file format for yukkuri is invalid", SimYukkuri.TITLE, JOptionPane.ERROR_MESSAGE);
11131046 e.printStackTrace();
11141047 System.exit(1);
@@ -1122,15 +1055,15 @@
11221055 // run animation
11231056 while (isRunning) {
11241057 int stress, speed;
1125- synchronized(SimYukkuri.lock) {
1058+ synchronized (SimYukkuri.lock) {
11261059 stress = 100 * Terrarium.bodyList.size() / Body.getHeadageLimit();
11271060 speed = gameSpeed[SimYukkuri.selectedGameSpeed];
11281061 }
1129- SimYukkuri.l3.setText(" "+InitLoader.getStatus(1)+": " + stress + "%");
1130- if(speed != PAUSE) {
1131- synchronized(SimYukkuri.lock) {
1062+ SimYukkuri.l3.setText(" " + InitLoader.getStatus(1) + ": " + stress + "%");
1063+ if (speed != PAUSE) {
1064+ synchronized (SimYukkuri.lock) {
11321065 terrarium.run();
1133- if(Terrarium.operationTime % 10 == 0) {
1066+ if (Terrarium.operationTime % 10 == 0) {
11341067 Logger.run();
11351068 }
11361069 }
@@ -1145,7 +1078,8 @@
11451078 else {
11461079 Thread.sleep(NORMAL);
11471080 }
1148- } catch (InterruptedException e) {
1081+ }
1082+ catch (InterruptedException e) {
11491083 e.printStackTrace();
11501084 System.exit(1);
11511085 }
@@ -1241,10 +1175,8 @@
12411175 List <ObjEX>platformList = Terrarium.getPlatformList();
12421176 for (Iterator<ObjEX> i = platformList.iterator(); i.hasNext();) {
12431177 ObjEX oex = i.next();
1244- int offsetX = (Body.MAXSIZE - oex.getSize())/2;
1245- int offsetY = (Body.MAXSIZE - oex.getSize()/2);
1246- int drX = Translate.transX(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1247- int drY = Translate.transY(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1178+ int drX = Translate.transX(oex.getX(), oex.getY(), oex.getSize(), w);
1179+ int drY = Translate.transY(oex.getX(), oex.getY(), oex.getSize()/2, h);
12481180
12491181 // fit the image to terrarium
12501182 Graphics2D g2d = (Graphics2D)g;
@@ -1256,21 +1188,18 @@
12561188 g2d.drawImage(oex.getImage(), translation, this); // Affine transform seems to be adapted to reverse order of concatenation.
12571189 // g.drawImage(oex.getImage(), drX, drY, this);
12581190 }
1259-
12601191 for (Obj o: Terrarium.toiletList) {
12611192 Toilet t = (Toilet)o;
1262- int offsetX = (Body.MAXSIZE - t.getSize())/2;
1263- int offsetY = (Body.MAXSIZE - t.getSize()*2/3);
1264- int drX = Translate.transX(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1265- int drY = Translate.transY(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1193+ int drX = Translate.transX(t.getX(), t.getY(), t.getSize(), w);
1194+ int drY = Translate.transY(t.getX(), t.getY(), t.getSize() * 2 / 3, h);
12661195 g.drawImage(t.getImage(), drX, drY, this);
12671196 }
12681197 // draw barriers
12691198 for (Barrier b: Terrarium.getBarriers()) {
1270- int SX = Translate.transX(b.getSX(), b.getSY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + Body.MAXSIZE/2;
1271- int SY = Translate.transY(b.getSX(), b.getSY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + Body.MAXSIZE;
1272- int EX = Translate.transX(b.getEX(), b.getEY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + Body.MAXSIZE/2;
1273- int EY = Translate.transY(b.getEX(), b.getEY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + Body.MAXSIZE;
1199+ int SX = Translate.transX(b.getSX(), b.getSY(), 0, w);
1200+ int SY = Translate.transY(b.getSX(), b.getSY(), 0, h);
1201+ int EX = Translate.transX(b.getEX(), b.getEY(), 0, w);
1202+ int EY = Translate.transY(b.getEX(), b.getEY(), 0, h);
12741203 Graphics2D g2 = (Graphics2D)g;
12751204 BasicStroke BStroke = new BasicStroke(6.0f);
12761205 Stroke DefStroke = g2.getStroke();
@@ -1281,10 +1210,10 @@
12811210 g2.setStroke(DefStroke);
12821211 }
12831212 if ((SimYukkuri.barrierSX >= 0) && (SimYukkuri.barrierSY >= 0) && (SimYukkuri.barrierEX >= 0) && (SimYukkuri.barrierEY >= 0)) {
1284- int SX = Translate.transX(SimYukkuri.barrierSX, SimYukkuri.barrierSY, Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + Body.MAXSIZE/2;
1285- int SY = Translate.transY(SimYukkuri.barrierSX, SimYukkuri.barrierSY, Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + Body.MAXSIZE;
1286- int EX = Translate.transX(SimYukkuri.barrierEX, SimYukkuri.barrierEY, Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + Body.MAXSIZE/2;
1287- int EY = Translate.transY(SimYukkuri.barrierEX, SimYukkuri.barrierEY, Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + Body.MAXSIZE;
1213+ int SX = Translate.transX(SimYukkuri.barrierSX, SimYukkuri.barrierSY, 0, w);
1214+ int SY = Translate.transY(SimYukkuri.barrierSX, SimYukkuri.barrierSY, 0, h);
1215+ int EX = Translate.transX(SimYukkuri.barrierEX, SimYukkuri.barrierEY, 0, w);
1216+ int EY = Translate.transY(SimYukkuri.barrierEX, SimYukkuri.barrierEY, 0, h);
12881217 Graphics2D g2 = (Graphics2D)g;
12891218 BasicStroke BStroke = new BasicStroke(6.0f);
12901219 Stroke DefStroke = g2.getStroke();
@@ -1295,16 +1224,13 @@
12951224 g2.setStroke(DefStroke);
12961225 }
12971226 // draw yukkuri, food and shit
1298- for (Obj o: list4sort) {
1227+ for (Obj o : list4sort) {
12991228 switch (o.objType) {
1300- case YUKKURI:
1301- {
1229+ case YUKKURI: {
13021230 Body b = (Body)o;
13031231 Body.AgeState ageState = b.getAgeState();
1304- int offsetX = (Body.MAXSIZE - b.getSize())/2;
1305- int offsetY = (Body.MAXSIZE - b.getSize());
1306- int drX = Translate.transX(b.getX(), b.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1307- int drY = Translate.transY(b.getX(), b.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1232+ int drX = Translate.transX(b.getX(), b.getY(), b.getSize(), w);
1233+ int drY = Translate.transY(b.getX(), b.getY(), b.getSize(), h);
13081234 int jump[] = {0, 8, 12, 14, 15, 14, 12, 8, 0};
13091235 int jumpLevel[] = {2, 2, 1};
13101236 double boundX[] = {0.00, -0.04, -0.02, -0.01, 0.00, 0.00, 0.00, 0.00, 0.08};
@@ -1313,12 +1239,12 @@
13131239 double surisuriY[] = {0.0, 0.05, 0.07, 0.08, 0.08, 0.08, 0.07, 0.05, 0.0};
13141240 double sleepingY[] = {0.0, 0.01, 0.02, 0.03, 0.03, 0.03, 0.02, 0.01, 0.0};
13151241 double bx = 1.0, by = 1.0;
1316- int bodysz = b.getSize();
1242+ int bodysz = b.getSize();
13171243
13181244 // draw shadow
13191245 g.drawImage(b.getShadowImage(), drX, drY, bodysz, bodysz, this);
13201246 // draw body
1321- drY -= b.getZ()*h/Terrarium.MAX_Z; // considering z axis
1247+ drY -= b.getZ() * h / Terrarium.MAX_Z; // considering z axis
13221248 int direction = b.getDirection().ordinal();
13231249 if ((!b.hasPants() && b.isShitting()) || b.isBirth()) {
13241250 g.drawImage(b.getImage(Body.SHIT, Body.LEFT), drX, drY, bodysz, bodysz, this);
@@ -1326,7 +1252,7 @@
13261252 g.drawImage(b.getImage(Body.PANTS2, Body.LEFT), drX, drY, bodysz, bodysz, this);
13271253 }
13281254 if (b.hasAccessory()) {
1329- g.drawImage(b.getImage(Body.ROLL_ACCESSORY, Body.LEFT), drX, drY, bodysz, bodysz, this);
1255+ g.drawImage(b.getImage(Body.ROLL_ACCESSORY, Body.LEFT), drX, drY, bodysz, bodysz, this);
13301256 }
13311257 }
13321258 else if (b.isFurifuri()) {
@@ -1342,7 +1268,7 @@
13421268 g.drawImage(b.getImage(Body.PANTS2_ROLL, dir), drX, drY, bodysz, bodysz, this);
13431269 }
13441270 if (b.hasAccessory()) {
1345- g.drawImage(b.getImage(Body.ROLL_ACCESSORY, Body.LEFT), drX, drY, bodysz, bodysz, this);
1271+ g.drawImage(b.getImage(Body.ROLL_ACCESSORY, Body.LEFT), drX, drY, bodysz, bodysz, this);
13461272 }
13471273 }
13481274 else if (b.isCrashed()) {
@@ -1350,7 +1276,7 @@
13501276 g.drawImage(b.getImage(Body.CRUSHED, Body.LEFT), drX, drY, bodysz, bodysz, this);
13511277 }
13521278 else {
1353- g.drawImage(b.getImage(Body.CRUSHED2, Body.LEFT), drX, drY, bodysz, bodysz, this);
1279+ g.drawImage(b.getImage(Body.CRUSHED2, Body.LEFT), drX, drY, bodysz, bodysz, this);
13541280 }
13551281 }
13561282 else {
@@ -1370,8 +1296,8 @@
13701296 else if (b.isExciting()) {
13711297 img = b.getImage(Body.EXCITING, direction);
13721298 if (!b.isGrabbed() && b.getZ() == 0) {
1373- drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState.ordinal()];
1374- drY -= jump[(int)b.getAge() % 9]/jumpLevel[ageState.ordinal()];
1299+ drY -= jump[(int)b.getAge() % 9] / jumpLevel[ageState.ordinal()];
1300+ drY -= jump[(int)b.getAge() % 9] / jumpLevel[ageState.ordinal()];
13751301 }
13761302 bx += boundX[(int)b.getAge() % 9];
13771303 by += boundY[(int)b.getAge() % 9];
@@ -1381,9 +1307,9 @@
13811307 by += sleepingY[((int)b.getAge() / 4) % 9];
13821308 }
13831309 else if (b.isPeroPero() || b.isEating()) {
1384- if (b.isStrike() || b.isVerySad() || b.isFeelHardPain() )
1310+ if (b.isStrike() || b.isVerySad() || b.isFeelHardPain())
13851311 img = b.getImage(Body.CRYING, direction);
1386- else if (b.isSad() || b.isEatingShit() || b.isFeelPain() )
1312+ else if (b.isSad() || b.isEatingShit() || b.isFeelPain())
13871313 img = b.getImage(Body.TIRED, direction);
13881314 else
13891315 img = b.getImage(Body.SMILE, direction);
@@ -1391,8 +1317,8 @@
13911317 else if (b.isSukkiri()) {
13921318 img = b.getImage(Body.REFRESHED, direction);
13931319 }
1394- else if (b.isDamaged() || b.isSick() || b.isFeelPain() ) {
1395- if (b.isStrike() || b.isVerySad() || b.isFeelHardPain() )
1320+ else if (b.isDamaged() || b.isSick() || b.isFeelPain()) {
1321+ if (b.isStrike() || b.isVerySad() || b.isFeelHardPain())
13961322 img = b.getImage(Body.CRYING, direction);
13971323 else
13981324 img = b.getImage(Body.TIRED, direction);
@@ -1409,19 +1335,19 @@
14091335 else if (b.isHappy())
14101336 img = b.getImage(Body.SMILE, direction);
14111337 else if (b.isTalking() && b.isRude())
1412- img = b.getImage(Body.RUDE,direction);
1338+ img = b.getImage(Body.RUDE, direction);
14131339 else if (b.isTalking() && !b.isRude())
1414- img = b.getImage(Body.CHEER,direction);
1340+ img = b.getImage(Body.CHEER, direction);
14151341 else if (rnd.nextInt(50) == 0) // for blink
14161342 img = b.getImage(Body.SLEEPING, direction);
14171343 else
1418- img = b.getImage(Body.NORMAL,direction);
1419- if (!b.isGrabbed() && b.getZ() == 0 && !b.isStaying()){
1420- drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState.ordinal()];
1421- drY -= jump[(int)b.getAge() % 9]/2/jumpLevel[ageState.ordinal()];
1344+ img = b.getImage(Body.NORMAL, direction);
1345+ if (!b.isGrabbed() && b.getZ() == 0 && !b.isStaying() && !b.hasBabies()) {
1346+ drY -= jump[(int)b.getAge() % 9] / 2 / jumpLevel[ageState.ordinal()];
1347+ drY -= jump[(int)b.getAge() % 9] / 2 / jumpLevel[ageState.ordinal()];
14221348 }
1423- bx += boundX[(int)b.getAge() % 9]/2;
1424- by += boundY[(int)b.getAge() % 9]/2;
1349+ bx += boundX[(int)b.getAge() % 9] / 2;
1350+ by += boundY[(int)b.getAge() % 9] / 2;
14251351 }
14261352 // Draw body
14271353 if (b.isRude()) {
@@ -1434,27 +1360,35 @@
14341360 bx *= 0.9; // make her thin
14351361 }
14361362 int saveDrX = drX;
1437- int bodyszX = (int)(bodysz*bx);
1438- int bodyszY = (int)(bodysz*by);
1439- drX -= (int)((bodyszX-bodysz)/2);
1440- drY -= (int)(bodyszY-bodysz);
1363+ int bodyszX = (int)(bodysz * bx);
1364+ int bodyszY = (int)(bodysz * by);
1365+ drX -= (int)((bodyszX - bodysz) / 2);
1366+ drY -= (int)(bodyszY - bodysz);
14411367 g.drawImage(b.getImage(Body.BODY, direction), drX, drY, bodyszX, bodyszY, this);
1368+ // Draw face
1369+ if (b.isDead()) {
1370+ g.drawImage(img, drX, drY, bodyszX, bodyszY, this); // face should be adjusted if it dies.
1371+ }
1372+ else {
1373+ g.drawImage(img, saveDrX, drY, bodysz, bodyszY, this); // face is not affected by bounce.
1374+ }
14421375 // Draw accessory
14431376 if (b.hasAccessory()) {
14441377 g.drawImage(b.getImage(Body.ACCESSORY, direction), drX, drY, bodyszX, bodyszY, this);
14451378 }
1446- // Draw face
1447- g.drawImage(img, saveDrX, drY, bodysz, bodysz, this); // face width is not affected by bound.
1379+ // Draw damage
14481380 if (b.isDamaged() || b.isOld()) {
14491381 g.drawImage(b.getImage(Body.DAMAGED, direction), drX, drY, bodyszX, bodyszY, this);
14501382 }
1451- // Draw pants and stain
1383+ // Draw pants
14521384 if (b.hasPants()) {
14531385 g.drawImage(b.getImage(Body.PANTS, direction), drX, drY, bodyszX, bodyszY, this);
14541386 }
1387+ // Draw stain
14551388 if (b.isDirty()) {
14561389 g.drawImage(b.getImage(Body.STAIN, direction), drX, drY, bodyszX, bodyszY, this);
14571390 }
1391+ // Draw yukabi
14581392 if (b.isSick()) {
14591393 g.drawImage(b.getImage(Body.SICK, direction), drX, drY, bodyszX, bodyszY, this);
14601394 }
@@ -1469,61 +1403,53 @@
14691403 }
14701404 // draw script
14711405 String message = b.getMessage();
1472- if (message != null)
1473- {
1474- final int FONTWIDTH=12;
1475- final int NUMOFCHAR=12;
1406+ if (message != null) {
1407+ final int FONTWIDTH = 12;
1408+ final int NUMOFCHAR = 12;
14761409 g.setFont(new Font(Font.MONOSPACED, Font.PLAIN, FONTWIDTH));
1477- int width = Math.min(message.length(), NUMOFCHAR)*FONTWIDTH;
1410+ int width = Math.min(message.length(), NUMOFCHAR) * FONTWIDTH;
14781411 int hight = drawStringMultiLine(g, message, 0, 0, width, false);
14791412 g.setColor(new Color(255, 255, 255, 200)); // transparent white.
1480- g.fillRoundRect(drX+14, drY-hight-4, width+8, hight+8, 8, 8);
1413+ g.fillRoundRect(drX + 14, drY - hight - 4, width + 8, hight + 8, 8, 8);
14811414 g.setColor(new Color(0, 0, 0, 255)); // no transparent black.
1482- g.drawRoundRect(drX+14, drY-hight-4, width+8, hight+8, 8, 8);
1483- drawStringMultiLine(g, message, drX+18, drY-hight, width, true);
1415+ g.drawRoundRect(drX + 14, drY - hight - 4, width + 8, hight + 8, 8, 8);
1416+ drawStringMultiLine(g, message, drX + 18, drY - hight, width, true);
14841417 }
1418+ break;
14851419 }
1486- break;
14871420 case FOOD: {
14881421 Food f = (Food)o;
1489- int offsetX = (Body.MAXSIZE - f.getSize())/2;
1490- int offsetY = (Body.MAXSIZE - f.getSize()/2);
1491- int drX = Translate.transX(f.getX(), f.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1492- int drY = Translate.transY(f.getX(), f.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1422+ int drX = Translate.transX(f.getX(), f.getY(), f.getSize(), w);
1423+ int drY = Translate.transY(f.getX(), f.getY(), f.getSize() / 2, h);
14931424 g.drawImage(f.getShadowImage(), drX, drY, this);
1494- drY -= f.getZ()*h/Terrarium.MAX_Z; // considering z axis
1495- g.drawImage(f.getImage(), drX, drY, this);
1425+ drY -= f.getZ() * h / Terrarium.MAX_Z; // considering z axis
1426+ g.drawImage(f.getImage(), drX, drY, this);
1427+ break;
14961428 }
1497- break;
14981429 case SHIT: {
14991430 Shit s = (Shit)o;
1500- int offsetX = (Body.MAXSIZE - s.getSize())/2;
1501- int offsetY = (Body.MAXSIZE - s.getSize());
1502- int drX = Translate.transX(s.getX(), s.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1503- int drY = Translate.transY(s.getX(), s.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1431+ int drX = Translate.transX(s.getX(), s.getY(), s.getSize(), w);
1432+ int drY = Translate.transY(s.getX(), s.getY(), s.getSize(), h);
15041433 g.drawImage(s.getShadowImage(), drX, drY, this);
1505- drY -= s.getZ()*h/Terrarium.MAX_Z; // considering z axis
1434+ drY -= s.getZ() * h / Terrarium.MAX_Z; // considering z axis
15061435 g.drawImage(s.getImage(), drX, drY, this);
1436+ break;
15071437 }
1508- break;
15091438 case TOY: {
15101439 Toy t = (Toy)o;
1511- int offsetX = (Body.MAXSIZE - t.getSize())/2;
1512- int offsetY = (Body.MAXSIZE - t.getSize());
1513- int drX = Translate.transX(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1514- int drY = Translate.transY(t.getX(), t.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1440+ int drX = Translate.transX(t.getX(), t.getY(), t.getSize(), w);
1441+ int drY = Translate.transY(t.getX(), t.getY(), t.getSize(), h);
15151442 g.drawImage(t.getShadowImage(), drX, drY, this);
1516- drY -= t.getZ()*h/Terrarium.MAX_Z; // considering z axis
1517- g.drawImage(t.getImage(), drX, drY, this);
1443+ drY -= t.getZ() * h / Terrarium.MAX_Z; // considering z axis
1444+ g.drawImage(t.getImage(), drX, drY, this);
1445+ break;
15181446 }
1519- break;
15201447 case FIX_OBJECT: {
15211448 ObjEX oex = (ObjEX)o;
1522- int offsetX = (Body.MAXSIZE - oex.getSize())/2;
1523- int offsetY = (Body.MAXSIZE - oex.getSize());
1524- int drX = Translate.transX(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(w-Body.MAXSIZE)/Terrarium.MAX_X + offsetX;
1525- int drY = Translate.transY(oex.getX(), oex.getY(), Terrarium.MAX_X, Terrarium.MAX_Y)*(h-Body.MAXSIZE)/Terrarium.MAX_Y + offsetY;
1526- g.drawImage(oex.getImage(), drX, drY, this);
1449+ int drX = Translate.transX(oex.getX(), oex.getY(), oex.getSize(), w);
1450+ int drY = Translate.transY(oex.getX(), oex.getY(), oex.getSize(), h);
1451+ g.drawImage(oex.getImage(), drX, drY, this);
1452+ break;
15271453 }
15281454 default:
15291455 break;
@@ -1848,20 +1774,42 @@
18481774 class Translate {
18491775 static final private double m = 1.0 / 8.0;
18501776 static final private double n = 7.0 / 8.0;
1777+ static final private int X = Terrarium.MAX_X;
1778+ static final private int Y = Terrarium.MAX_Y;
1779+ static final private int MAXSIZE = Body.MAXSIZE;
18511780
1852- static public int transX(int x, int y, int X, int Y) {
1853- return (int)(((n-m)*Y*x - m*X*y + m*X*Y)/((n-m-1)*y + Y));
1781+ static public int transX(int x, int y) {
1782+ return (int)(((n - m) * Y * x - m * X * y + m * X * Y) / ((n - m - 1) * y + Y));
18541783 }
18551784
1856- static public int transY(int x, int y, int X, int Y) {
1857- return (int)(((n-m)*Y*y)/((n-m-1)*y + Y));
1785+ static public int transY(int x, int y) {
1786+ return (int)(((n - m) * Y * y) / ((n - m - 1) * y + Y));
18581787 }
18591788
1860- static public int invX(int x, int y, int X, int Y) {
1861- return (int)((Y*x + m*X*y - m*X*Y)/((n-m)*Y - (n-m-1)*y));
1789+ static public int transX(int x, int y, int size, int width) {
1790+ return (int)(((n - m) * Y * x - m * X * y + m * X * Y) / ((n - m - 1) * y + Y) * (width - MAXSIZE) / X + (MAXSIZE - size) / 2);
18621791 }
18631792
1864- static public int invY(int x, int y, int X, int Y) {
1865- return (int)(Y*y/((n-m)*Y - (n-m-1)*y));
1793+ static public int transY(int x, int y, int size, int hight) {
1794+ return (int)(((n - m) * Y * y) / ((n - m - 1) * y + Y) * (hight - MAXSIZE) / Y + MAXSIZE - size);
18661795 }
1796+
1797+ static public int invX(int x, int y) {
1798+ return (int)((Y * x + m * X * y - m * X * Y) / ((n - m) * Y - (n - m - 1) * y));
1799+ }
1800+
1801+ static public int invY(int x, int y) {
1802+ return (int)(Y * y / ((n - m) * Y - (n - m - 1) * y));
1803+ }
1804+
1805+ static public int invX(int x, int y, int size, int width, int hight) {
1806+ int x2 = (x - (MAXSIZE - size) / 2) * X / (width - MAXSIZE);
1807+ int y2 = (y - (MAXSIZE - size)) * Y / (hight - MAXSIZE);
1808+ return (int)((Y * x2 + m * X * y2 - m * X * Y) / ((n - m) * Y - (n - m - 1) * y2));
1809+ }
1810+
1811+ static public int invY(int x, int y, int size, int width, int hight) {
1812+ int y2 = (y - (MAXSIZE - size)) * Y / (hight - MAXSIZE);
1813+ return (int)(Y * y2 / ((n - m) * Y - (n - m - 1) * y2));
1814+ }
18671815 }
--- branches/test/Cash.java (revision 254)
+++ branches/test/Cash.java (revision 255)
@@ -1,5 +1,5 @@
11 /*
2- * Copyright 2015 Mimisuke
2+ * Copyright 2013-2015 Cantreadcode and Mimisuke
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
Show on old repository browser