svn: r3638
This commit is contained in:
parent
c3c98ebd6c
commit
f537365c27
|
@ -22,7 +22,7 @@ public abstract class GameWorld extends World {
|
||||||
((GameWorld) newWorld).timer = ((GameWorld) oldWorld).timer;
|
((GameWorld) newWorld).timer = ((GameWorld) oldWorld).timer;
|
||||||
newWorld.display = oldWorld.display;
|
newWorld.display = oldWorld.display;
|
||||||
display.allowImage(false);
|
display.allowImage(false);
|
||||||
oldWorld.erase();
|
// oldWorld.erase();
|
||||||
newWorld.draw();
|
newWorld.draw();
|
||||||
display.allowImage(true);
|
display.allowImage(true);
|
||||||
}
|
}
|
||||||
|
@ -56,39 +56,3 @@ public abstract class GameWorld extends World {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* class TimerCallBack {
|
|
||||||
private World nextWorld;
|
|
||||||
TimerCallBack( World w) {
|
|
||||||
nextWorld = w;
|
|
||||||
}
|
|
||||||
public void callBack() {
|
|
||||||
rename.printer(nextWorld.toString());
|
|
||||||
nextWorld.erase();
|
|
||||||
nextWorld = nextWorld.onTick();
|
|
||||||
rename.printer(nextWorld.toString());
|
|
||||||
nextWorld.draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void updateNextWorld(World w) {
|
|
||||||
rename.printer("Calling update "+this.toString());
|
|
||||||
nextWorld = w;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class KeyCallBack {
|
|
||||||
private World nextWorld;
|
|
||||||
private TimerCallBack t;
|
|
||||||
|
|
||||||
KeyCallBack( World w, TimerCallBack t) {
|
|
||||||
nextWorld = w;
|
|
||||||
this.t = t;
|
|
||||||
}
|
|
||||||
public void callBack(dynamic key) {
|
|
||||||
rename.printer(key);
|
|
||||||
nextWorld = nextWorld.onKey(key);
|
|
||||||
rename.printer("Should call updateNextWorld next"+nextWorld.toString());
|
|
||||||
t.updateNextWorld(this.nextWorld);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -28,7 +28,7 @@ public class Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image overlayXY( Image i, Posn p) {
|
public Image overlayXY( Image i, Posn p) {
|
||||||
return new Image( rename.overlayXY( theImage, i.theImage, p.x, p.y));
|
return new Image( rename.overlayXY( theImage, p.x, p.y, i.theImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Posn getPinhole() {
|
public Posn getPinhole() {
|
||||||
|
|
|
@ -11,28 +11,35 @@ public class PictureFactory {
|
||||||
this.pinholeInCenter = pinholeInCenter;
|
this.pinholeInCenter = pinholeInCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image setPinhole(Image i ) {
|
||||||
|
if (pinholeInCenter)
|
||||||
|
return i;
|
||||||
|
else
|
||||||
|
return i.putPinhole(new Posn(0,0));
|
||||||
|
}
|
||||||
|
|
||||||
public Image makeCircle( int r, String mode, Color c) {
|
public Image makeCircle( int r, String mode, Color c) {
|
||||||
return new Image( image.circle( r, rename.toSymbol(mode), c.toString() ) );
|
return setPinhole(new Image( image.circle( r, rename.toSymbol(mode), c.toString() ) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image makeRectangle( int width, int height, String mode, Color c) {
|
public Image makeRectangle( int width, int height, String mode, Color c) {
|
||||||
return new Image( image.rectangle( width, height, rename.toSymbol(mode), c.toString() ));
|
return setPinhole(new Image( image.rectangle( width, height, rename.toSymbol(mode), c.toString() )));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image makeEllipse( int width, int height, String mode, Color c) {
|
public Image makeEllipse( int width, int height, String mode, Color c) {
|
||||||
return new Image( image.ellipse( width, height, rename.toSymbol(mode), c.toString() ));
|
return setPinhole(new Image( image.ellipse( width, height, rename.toSymbol(mode), c.toString() )));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image makeTriangle( int edge, String mode, Color c) {
|
public Image makeTriangle( int edge, String mode, Color c) {
|
||||||
return new Image( image.triangle( edge, rename.toSymbol(mode), c.toString() ));
|
return setPinhole(new Image( image.triangle( edge, rename.toSymbol(mode), c.toString() )));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image makeLine( Posn to, Color c) {
|
public Image makeLine( Posn to, Color c) {
|
||||||
return new Image( image.line(to.x,to.y,c.toString()));
|
return setPinhole(new Image( image.line(to.x,to.y,c.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Image makeText( String text, int ptSize, Color c) {
|
public Image makeText( String text, int ptSize, Color c) {
|
||||||
return new Image( image.text( text, ptSize, c.toString() ) );
|
return setPinhole(new Image( image.text( text, ptSize, c.toString() ) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -73,11 +73,11 @@ public class View {
|
||||||
|
|
||||||
//The Image is again an equality testable version of the canvas after applying all commands
|
//The Image is again an equality testable version of the canvas after applying all commands
|
||||||
//Issues the commands in reverse order
|
//Issues the commands in reverse order
|
||||||
// public Image drawSequence( CommandSequence commands ) {
|
public Image drawSequence( CommandSequence commands ) {
|
||||||
// commands.drawAll(this);
|
commands.drawAll(this);
|
||||||
// dc.drawBitmap(buffer.getBitmap(), 0 ,0);
|
dc.drawBitmap(buffer.getBitmap(), 0 ,0);
|
||||||
// return getBufferCopy();
|
return getBufferCopy();
|
||||||
// }
|
}
|
||||||
|
|
||||||
//Methods not seen by students
|
//Methods not seen by students
|
||||||
|
|
||||||
|
@ -121,4 +121,9 @@ public class View {
|
||||||
//c.issue(buffer);
|
//c.issue(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawToCanvas( Command c) {
|
||||||
|
if (!visible)
|
||||||
|
throw new RuntimeException("View must be displayed in order to draw in it");
|
||||||
|
c.issue(buffer);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -24,14 +24,14 @@
|
||||||
(javac "Red.java")
|
(javac "Red.java")
|
||||||
(javac "White.java")
|
(javac "White.java")
|
||||||
(javac "Yellow.java")
|
(javac "Yellow.java")
|
||||||
;(javac "Command.djava")
|
(javac "Command.djava")
|
||||||
;(javac "DrawLine.djava")
|
(javac "DrawLine.djava")
|
||||||
;(javac "DrawRectangle.djava")
|
(javac "DrawRectangle.djava")
|
||||||
;(javac "DrawImage.djava")
|
(javac "DrawImage.djava")
|
||||||
(javac "View.djava")
|
(javac "View.djava")
|
||||||
;(javac "CommandSequence.java")
|
(javac "CommandSequence.java")
|
||||||
;(javac "LargerSeq.java")
|
(javac "LargerSeq.java")
|
||||||
;(javac "EmptySeq.java")
|
(javac "EmptySeq.java")
|
||||||
(javac "World.java")
|
(javac "World.java")
|
||||||
(javac "GameWorld.djava")
|
(javac "GameWorld.djava")
|
||||||
)))
|
)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user