parent
7c4af9bef1
commit
91cd4ad128
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 the original author or authors.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
* applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||||
|
* OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.github.drinkjava2.frog.brain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.github.drinkjava2.frog.Env;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cuboid represents a rectangular prism zone in brain
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public class Cuboid implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float z;
|
||||||
|
public float xr;// xr为这个矩形体x边长的一半
|
||||||
|
public float yr;// yr为这个矩形体y边长的一半
|
||||||
|
public float zr;// zr为这个矩形体z边长的一半
|
||||||
|
|
||||||
|
public Cuboid() {
|
||||||
|
// 空构造器不能省
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cuboid(float x, float y, float z, float r) {// 用x,y,z,r来构造
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.xr = r;
|
||||||
|
this.yr = r;
|
||||||
|
this.zr = r;
|
||||||
|
if (this.x < 0)
|
||||||
|
this.x = 0;
|
||||||
|
if (this.y < 0)
|
||||||
|
this.y = 0;
|
||||||
|
if (this.x > Env.FROG_BRAIN_RADIUS)
|
||||||
|
this.x = Env.FROG_BRAIN_RADIUS;
|
||||||
|
if (this.y > Env.FROG_BRAIN_RADIUS)
|
||||||
|
this.y = Env.FROG_BRAIN_RADIUS;
|
||||||
|
if (this.z > Env.FROG_BRAIN_RADIUS)
|
||||||
|
this.z = Env.FROG_BRAIN_RADIUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cuboid(float x, float y, float z, float xr, float yr, float zr) {// 用x,y,z,r来构造
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.xr = xr;
|
||||||
|
this.yr = yr;
|
||||||
|
this.zr = zr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cuboid(Cuboid c) {// 用另一个Cube来构造
|
||||||
|
this.x = c.x;
|
||||||
|
this.y = c.y;
|
||||||
|
this.z = c.z;
|
||||||
|
this.xr = c.xr;
|
||||||
|
this.yr = c.yr;
|
||||||
|
this.zr = c.zr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyXYZ(Cuboid from, Cuboid to) {
|
||||||
|
to.x = from.x;
|
||||||
|
to.y = from.y;
|
||||||
|
to.z = from.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyXYZR(Cuboid from, Cuboid to) {
|
||||||
|
to.x = from.x;
|
||||||
|
to.y = from.y;
|
||||||
|
to.z = from.z;
|
||||||
|
to.xr = from.xr;
|
||||||
|
to.xr = from.xr;
|
||||||
|
to.xr = from.xr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,99 @@
|
|||||||
|
package com.github.drinkjava2.frog.brain;
|
||||||
|
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.event.MouseListener;
|
||||||
|
import java.awt.event.MouseMotionListener;
|
||||||
|
import java.awt.event.MouseWheelEvent;
|
||||||
|
import java.awt.event.MouseWheelListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BrainPicture show first frog's brain structure, for debug purpose only
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public class MouseAction implements MouseListener, MouseWheelListener, MouseMotionListener {
|
||||||
|
private BrainPicture brainPic;
|
||||||
|
private int buttonPressed = 0;
|
||||||
|
private int x;
|
||||||
|
private int y;
|
||||||
|
|
||||||
|
public MouseAction(BrainPicture brainPic) {
|
||||||
|
this.brainPic = brainPic;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.getButton() == 1)
|
||||||
|
buttonPressed = 1;
|
||||||
|
else if (e.getButton() == 2)
|
||||||
|
buttonPressed = 2;
|
||||||
|
else
|
||||||
|
buttonPressed = 0;
|
||||||
|
x = e.getPoint().x;
|
||||||
|
y = e.getPoint().y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
buttonPressed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
|
if (e.getWheelRotation() < 0)
|
||||||
|
brainPic.scale *= 1.1;
|
||||||
|
else
|
||||||
|
brainPic.scale /= 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {// do nothing
|
||||||
|
if (buttonPressed == 1) {
|
||||||
|
if (e.getX() > x && e.getY() > y)
|
||||||
|
brainPic.zAngle -= .00f;
|
||||||
|
else if (e.getX() < x && e.getY() < y)
|
||||||
|
brainPic.zAngle += .00f;
|
||||||
|
else {
|
||||||
|
if (e.getX() > x)
|
||||||
|
brainPic.yAngle += .02f;
|
||||||
|
if (e.getX() < x)
|
||||||
|
brainPic.yAngle -= .02f;
|
||||||
|
if (e.getY() > y)
|
||||||
|
brainPic.xAngle -= .02f;
|
||||||
|
if (e.getY() < y)
|
||||||
|
brainPic.xAngle += .02f;
|
||||||
|
}
|
||||||
|
x = e.getX();
|
||||||
|
y = e.getY();
|
||||||
|
}
|
||||||
|
if (buttonPressed == 2) {
|
||||||
|
if (e.getX() > x)
|
||||||
|
brainPic.xOffset++;
|
||||||
|
if (e.getX() < x)
|
||||||
|
brainPic.xOffset--;
|
||||||
|
if (e.getY() > y)
|
||||||
|
brainPic.yOffset++;
|
||||||
|
if (e.getY() < y)
|
||||||
|
brainPic.yOffset--;
|
||||||
|
x = e.getX();
|
||||||
|
y = e.getY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) { // do nothing
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 the original author or authors.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
* applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||||
|
* OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.github.drinkjava2.frog.brain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Point has x, y, z value
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
* @since 2.0.2
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public class Point {
|
||||||
|
public float x;
|
||||||
|
public float y;
|
||||||
|
public float z;
|
||||||
|
|
||||||
|
public Point(float x, float y, float z) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
}
|
||||||
|
}
|
@ -1,84 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2018 the original author or authors.
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
||||||
* use this file except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
|
||||||
* applicable law or agreed to in writing, software distributed under the
|
|
||||||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
|
||||||
* OF ANY KIND, either express or implied. See the License for the specific
|
|
||||||
* language governing permissions and limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.github.drinkjava2.frog.brain;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import com.github.drinkjava2.frog.Env;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Zone represents a rectangle zone in brain
|
|
||||||
*
|
|
||||||
* @author Yong Zhu
|
|
||||||
* @since 1.0
|
|
||||||
*/
|
|
||||||
public class Zone implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public float x;
|
|
||||||
public float y;
|
|
||||||
public float r;// r为这个矩形区边长的一半
|
|
||||||
|
|
||||||
public Zone() {
|
|
||||||
// 空构造器不能省
|
|
||||||
}
|
|
||||||
|
|
||||||
public Zone(float x, float y, float r) {// 用x,y,r来构造
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.r = r;
|
|
||||||
if (this.x < 0)
|
|
||||||
this.x = 0;
|
|
||||||
if (this.y < 0)
|
|
||||||
this.y = 0;
|
|
||||||
if (this.x > Env.FROG_BRAIN_WIDTH)
|
|
||||||
this.x = Env.FROG_BRAIN_WIDTH;
|
|
||||||
if (this.y > Env.FROG_BRAIN_WIDTH)
|
|
||||||
this.y = Env.FROG_BRAIN_WIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Zone(Zone z) {// 用另一个Zone来构造
|
|
||||||
this.x = z.x;
|
|
||||||
this.y = z.y;
|
|
||||||
this.r = z.r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean nearby(Zone z) {
|
|
||||||
float dist = r + z.r;
|
|
||||||
return (Math.abs(x - z.x) < dist && Math.abs(y - z.y) < dist);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int roundX() {
|
|
||||||
return Math.round(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int roundY() {
|
|
||||||
return Math.round(y);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyXY(Zone from, Zone to) {
|
|
||||||
to.x = from.x;
|
|
||||||
to.y = from.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyXYR(Zone from, Zone to) {
|
|
||||||
to.x = from.x;
|
|
||||||
to.y = from.y;
|
|
||||||
to.r = from.r;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXYR(float x, float y, float r) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.r = r;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 the original author or authors.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
* applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||||
|
* OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.github.drinkjava2.frog.brain.organ;
|
||||||
|
|
||||||
|
import com.github.drinkjava2.frog.Env;
|
||||||
|
import com.github.drinkjava2.frog.brain.Organ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BrainFrame one used to drawing the brain frame in BrainPicture
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
*/
|
||||||
|
public class BrainFrame extends Organ {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public BrainFrame() {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = 0;
|
||||||
|
xr = Env.FROG_BRAIN_RADIUS / 2;
|
||||||
|
yr = xr;
|
||||||
|
zr = xr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowBorrow() { // 是否允许在精子中将这个器官借出
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 the original author or authors.
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
* applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||||
|
* OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.github.drinkjava2.frog.brain.organ;
|
||||||
|
|
||||||
|
import com.github.drinkjava2.frog.Env;
|
||||||
|
import com.github.drinkjava2.frog.brain.Organ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PictureEye can only see the picture in env
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
*/
|
||||||
|
public class PictureEye extends Organ {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public PictureEye() {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
z = Env.FROG_BRAIN_RADIUS / 2 - .5f;
|
||||||
|
xr = Env.FROG_BRAIN_RADIUS / 4;
|
||||||
|
yr = xr;
|
||||||
|
zr = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowBorrow() { // 是否允许在精子中将这个器官借出
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/* Copyright 2018-2020 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||||
|
* use this file except in compliance with the License. You may obtain a copy of
|
||||||
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
|
||||||
|
* applicable law or agreed to in writing, software distributed under the
|
||||||
|
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
|
||||||
|
* OF ANY KIND, either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.github.drinkjava2.frog.objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object means some thing in Env
|
||||||
|
*
|
||||||
|
* @author Yong Zhu
|
||||||
|
* @since 1.0
|
||||||
|
*/
|
||||||
|
public class Pictures implements Object {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void build() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destory() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void active(int screen) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in new issue