Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JadarTheObscurity committed May 27, 2020
1 parent a3b5c26 commit 298dbd7
Show file tree
Hide file tree
Showing 201 changed files with 3,374 additions and 0 deletions.
Binary file added Animation.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Animation.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Animation
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Animation\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=num
comment1.target=Animation(int)
comment2.params=
comment2.target=void\ act()
comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ Animation\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment3.params=
comment3.target=boolean\ end()
numComments=4
31 changes: 31 additions & 0 deletions Animation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Animation here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Animation extends Actor
{
public int act_count = 0;
public int image_num = 0;

public Animation(int num){
act_count = 0;
image_num = num;
}

/**
* Act - do whatever the Animation wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}

public boolean end(){
return act_count >= image_num;
}
}
Binary file added Barrier.class
Binary file not shown.
9 changes: 9 additions & 0 deletions Barrier.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Barrier
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Barrier\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=Barrier()
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ Barrier\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment2.params=
comment2.target=void\ act()
numComments=3
23 changes: 23 additions & 0 deletions Barrier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Barrier here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Barrier extends Actor
{
/**
* Act - do whatever the Barrier wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Barrier(){

}

public void act()
{
// Add your action code here.
}
}
Binary file added Bullet.class
Binary file not shown.
19 changes: 19 additions & 0 deletions Bullet.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#BlueJ class context
comment0.target=Bullet
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Bullet\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=init_pos\ init_speed\ direction
comment1.target=Bullet(Point,\ Point,\ double)
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ Bullet\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment2.params=
comment2.target=void\ act()
comment3.params=
comment3.target=void\ move()
comment4.params=init_speed\ direction
comment4.target=void\ setSpeed(Point,\ double)
comment5.params=
comment5.target=boolean\ hitMover()
comment6.params=
comment6.target=boolean\ hitBarrier()
comment7.params=
comment7.target=void\ removeTouching()
numComments=8
73 changes: 73 additions & 0 deletions Bullet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Bullet here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Bullet extends Mover
{
Point m_speed;
Point init_pos;
int act_count = 1;
/**
* Act - do whatever the Bullet wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Bullet(Point init_pos, Point init_speed, double direction){
super(6);
setLocation(init_pos);
setSpeed(init_speed, direction);
this.init_pos = init_pos;
act_count = 1;
}



public void act()
{
move();
act_count++;
// Add your action code here.
}
public void move(){
Point displacement = new Point(m_speed);
displacement.scale(act_count);
displacement.y *= -1;//reverse y axis to match the stupid coordinate
setLocation(MyMath.add(init_pos, displacement));
}
public void setSpeed(Point init_speed, double direction){

setRotation((int)MyMath.angleInRange(-direction));
//direction = Math.toRadians(direction);
direction *= 0.0175;
m_speed = new Point(Math.cos(direction), Math.sin(direction));

m_speed.setLength(getMaxSpeed());
m_speed = MyMath.add(init_speed, m_speed);
//setRotation((int)MyMath.angleInRange(-m_speed.getTheta()));
}



public boolean hitMover(){
return isTouching(Mover.class);
}

public boolean hitBarrier(){
return isTouching(Barrier.class);
}

public void removeTouching(){
List<TankBody> allTouched = getIntersectingObjects(TankBody.class);
for(TankBody t : allTouched){
((TankWorld)getWorld()).removeObject(t.m_turret);
((TankWorld)getWorld()).removeObject(t);
}
removeTouching(Mover.class);
}


}

Binary file added Explosion.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Explosion.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Explosion
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Explosion\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=Explosion()
comment2.params=
comment2.target=void\ act()
comment2.text=\r\n\ Act\ -\ do\ whatever\ the\ Explosion\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment3.params=
comment3.target=void\ playAnimation()
numComments=4
36 changes: 36 additions & 0 deletions Explosion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Explosion here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Explosion extends Animation
{
String image_path = "Explode_";
private GreenfootImage image = new GreenfootImage(image_path + 0 + ".png");

public Explosion(){
super(65);
}
/**
* Act - do whatever the Explosion wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
playAnimation();
// Add your action code here.
}

public void playAnimation(){
if(act_count < image_num){
image = new GreenfootImage(image_path + act_count + ".png");
setImage(image);
}
act_count++;
}


}
Binary file added GetEricStupidJson.class
Binary file not shown.
6 changes: 6 additions & 0 deletions GetEricStupidJson.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#BlueJ class context
comment0.target=GetEricStupidJson
comment0.text=\r\n\ Write\ a\ description\ of\ class\ GetEricStupidJson\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=void\ main()
numComments=2
40 changes: 40 additions & 0 deletions GetEricStupidJson.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.*;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;


/**
* Write a description of class GetEricStupidJson here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class GetEricStupidJson
{
// instance variables - replace the example below with your own
public void main(){
//JSONArray j = JSONArray.fromObject("[1,2]");
// System.out.println(j.toString());
/**
String url = "http://192.168.1.106:8080/test/test.json";
InputStream is = new URL(url).openStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(is,"utf-8")); //�?��?中文亂碼�?題
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
JSONObject json = JSONObject.fromObject(sb.toString());
System.out.println(json.get("hello"));
} finally {
is.close();
}
**/
}
}
Binary file added Mover.class
Binary file not shown.
27 changes: 27 additions & 0 deletions Mover.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#BlueJ class context
comment0.target=Mover
comment0.text=\r\n\ Write\ a\ description\ of\ class\ Mover\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=
comment1.target=Mover()
comment1.text=\r\n\ Act\ -\ do\ whatever\ the\ Mover\ wants\ to\ do.\ This\ method\ is\ called\ whenever\r\n\ the\ 'Act'\ or\ 'Run'\ button\ gets\ pressed\ in\ the\ environment.\r\n
comment10.params=speed
comment10.target=void\ setMaxSpeed(double)
comment11.params=
comment11.target=double\ getMaxSpeed()
comment2.params=max_speed
comment2.target=Mover(double)
comment3.params=
comment3.target=void\ act()
comment4.params=speed
comment4.target=void\ setSpeed(Point)
comment5.params=
comment5.target=Point\ getSpeed()
comment6.params=
comment6.target=void\ move()
comment7.params=pos
comment7.target=void\ setLocation(Point)
comment8.params=
comment8.target=Point\ getLocation()
comment9.params=
comment9.target=Point\ getLastPos()
numComments=12
75 changes: 75 additions & 0 deletions Mover.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
* Write a description of class Mover here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Mover extends Actor
{
private Point speed = new Point(0, 0);
private double max_speed = 5;
private Point last_pos = new Point(0,0);
private Point pos;
/**
* Act - do whatever the Mover wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Mover(){

}

public Mover(double max_speed){
this.max_speed = max_speed;
}
public void act()
{
move();
// Add your action code here.
}

public void setSpeed(Point speed){
this.speed = speed;
if(speed.getLength() > max_speed)
this.speed.setLength(max_speed);
}

public Point getSpeed(){
return speed;
}

public void move(){
last_pos.x = getX();
last_pos.y = getY();
if(pos == null){
pos = new Point(getX(), getY());
}
else{
pos.x += speed.x;
pos.y -= speed.y;
}
setLocation((int)pos.x, (int)pos.y);
}

public void setLocation(Point pos){
setLocation((int)pos.x, (int)pos.y);
}

public Point getLocation(){
return new Point(getX(), getY());
}

public Point getLastPos(){
return last_pos;
}

public void setMaxSpeed(double speed){
max_speed = speed;
}

public double getMaxSpeed(){
return max_speed;
}

}
Binary file added MyMath.class
Binary file not shown.
10 changes: 10 additions & 0 deletions MyMath.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#BlueJ class context
comment0.target=MyMath
comment0.text=\r\n\ Write\ a\ description\ of\ class\ MyMath\ here.\r\n\ \r\n\ @author\ (your\ name)\ \r\n\ @version\ (a\ version\ number\ or\ a\ date)\r\n
comment1.params=a\ b
comment1.target=Point\ add(Point,\ Point)
comment2.params=a\ b
comment2.target=double\ dot(Point,\ Point)
comment3.params=angle
comment3.target=double\ angleInRange(double)
numComments=4
Loading

0 comments on commit 298dbd7

Please sign in to comment.