Package com.sirenian.hellbound.domain

Examples of com.sirenian.hellbound.domain.Segments


        PseudoRandomGlyphFactory factory = new PseudoRandomGlyphFactory(42, 7, 13); // T, Z, S, J...
        Mock glyphListener = mock(GlyphListener.class);
        Game game = new Game(factory, heartbeat, 7, 13);
        game.addGlyphListener((GlyphListener) glyphListener);
       
        Segments initialSegments = GlyphType.T.getSegments(0).movedRight(3);
       
        glyphListener.stubs("reportGlyphMovement").with(eq(GlyphType.JUNK), anything(), anything());
        glyphListener.expects("reportGlyphMovement").with(eq(GlyphType.T), anything(), eq(initialSegments));
        glyphListener.expects("reportGlyphMovement").with(eq(GlyphType.T), eq(initialSegments), eq(initialSegments.movedDown()));
        game.requestStartGame();
        heartbeat.beat();
       
        verifyMocks();
    }
View Full Code Here


  }
   
    public void shouldMoveGlyphWhenRequested() {
        AccessibleFactory factory  = new AccessibleFactory(7);
        Game game = new Game(factory, new StubHeartbeat(), 7, 13);
        Segments latestSegments = GlyphType.T.getSegments(0).movedRight(3);
        game.requestStartGame();
              
        game.requestGlyphMovement(GlyphMovement.ROTATE_LEFT);
        ensureThat(factory.glyph.getSegments(), eq(GlyphType.T.getSegments(1).movedRight(3)));
       
        game.requestGlyphMovement(GlyphMovement.ROTATE_RIGHT);
        ensureThat(factory.glyph.getSegments(), eq(GlyphType.T.getSegments(0).movedRight(3)));

        game.requestGlyphMovement(GlyphMovement.LEFT);
        ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedLeft()));
        latestSegments = latestSegments.movedLeft();
       
        game.requestGlyphMovement(GlyphMovement.RIGHT);
        ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedRight()));
        latestSegments = latestSegments.movedRight();

        game.requestGlyphMovement(GlyphMovement.DOWN);
        ensureThat(factory.glyph.getSegments(), eq(latestSegments.movedDown()));
        latestSegments = latestSegments.movedDown();
       
        verifyMocks();
    }
View Full Code Here

        glyphFactoryMock.expects("nextGlyph").inOrder()
            .with(new Matcher[] {isA(CollisionDetector.class), isA(ListenerSet.class)})
            .will(returnValue(firstGlyph), returnValue(secondGlyph));
        glyphFactoryMock.expects("createJunk").with(isA(ListenerSet.class)).will(returnValue(junk));

        Segments segmentsForTShapeOnFloor = droppedToFloor(GlyphType.T.getSegments(0).movedRight(3), 13);
       
        Game game = new Game((GlyphFactory) glyphFactoryMock, heartbeat, 7, 13);
        game.requestStartGame();
       
        // When...
View Full Code Here

                return holder.glyph;
            }
        }, new StubHeartbeat(), 3, 13);
        game.requestStartGame();
       
        Segments originalSegments = holder.glyph.getSegments();
       
        game.requestGlyphMovement(GlyphMovement.RIGHT);
        ensureThat(holder.glyph.getSegments(), eq(originalSegments));
       
        game.requestGlyphMovement(GlyphMovement.LEFT);
View Full Code Here

        ensureThat(!heartbeat.isBeating());
       
    }
   
    private Segments droppedToFloor(Segments segments, int floor) {
        Segments result = segments;
        while(result.lowest() < floor) {
            result = result.movedDown();
        }
        return result;
    }
View Full Code Here

import com.sirenian.hellbound.domain.glyph.GlyphType;
import com.sirenian.hellbound.gui.RenderedPit;

public class TheGlyphShouldMoveDownwards extends HellboundOutcome {
  public void verifyAnyTimeIn(World world) {
      Segments expectedSegments = T_SHAPE_AT_TOP.movedDown();
      Color expectedColor = Hellbound.COLORMAP.getColorFor(GlyphType.T);
        RenderedPit pit = getPit(world);
        Ensure.that(pit, contains(expectedSegments, expectedColor));
  }
View Full Code Here

        this.width = width;
        this.height = height;
  }

    public void absorb(LivingGlyph glyph) {
        Segments newSegments = segments.add(glyph.getSegments());
        glyph.kill();
        newSegments = removeAnyFilledLines(newSegments);
        moveTo(newSegments);
    }
View Full Code Here

        newSegments = removeAnyFilledLines(newSegments);
        moveTo(newSegments);
    }

    private Segments removeAnyFilledLines(Segments newSegments) {
        Segments results = newSegments;
        for (int y = 0; y < height; y++) {
            boolean lineFilled = true;
            for (int x = 0; x < width && lineFilled; x++) {
                if (!results.contains(new Segment(x, y))) {
                    lineFilled = false;
                }
            }
            if (lineFilled) {
                results = removeLine(results, y);
View Full Code Here

        }
        return results;
    }

    private Segments removeLine(Segments newSegments, int y) {
        Segments results = newSegments;
        for (int x = 0; x < width; x++) {
            results = results.remove(new Segment(x, y));
        }
       
        for (int j = y - 1; j >= 0; j--) {
            for (int x = 0; x < width; x++) {
                if (newSegments.contains(new Segment(x, j))) {
                    results = results.replace(new Segment(x, j), new Segment(x, j + 1));
                }
               
            }
        }
        return results;
View Full Code Here

            return true;
        }
    }
   
  public void drop() {
    Segments segmentsToMoveTo = segments;
    Segments nextSegmentsDown = segments.movedDown();
    while (!detector.collides(nextSegmentsDown)) {
      segmentsToMoveTo = nextSegmentsDown;
      nextSegmentsDown = nextSegmentsDown.movedDown();
    }
    moveTo(segmentsToMoveTo);
  }
View Full Code Here

TOP

Related Classes of com.sirenian.hellbound.domain.Segments

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.