Changeset 33342 in osm


Ignore:
Timestamp:
2017-05-27T22:56:30+02:00 (7 years ago)
Author:
stoecker
Message:

checkstyle fixes

Location:
applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge/EngineSound.java

    r32914 r33342  
    11/*
    22 * GPLv2 or 3, Copyright (c) 2010  Andrzej Zaborowski
    3  *
    4  * This class simulates a car engine.  What does a car engine do?  It
    5  * makes a pc-speaker-like buzz.  The PC Speaker could only emit
    6  * a (nearly) square wave and we simulate it here for maximum realism.
    73 */
    84package wmsturbochallenge;
     
    1612import javax.sound.sampled.SourceDataLine;
    1713
     14/**
     15 * This class simulates a car engine.  What does a car engine do?  It
     16 * makes a pc-speaker-like buzz.  The PC Speaker could only emit
     17 * a (nearly) square wave and we simulate it here for maximum realism.
     18 */
    1819class EngineSound {
    19     public EngineSound() {
     20    EngineSound() {
    2021        rpm = 0.0;
    2122    }
     
    7980        if (accel > 0.0 && rpm > 1.0 + n * 0.2 && speed > 0.0) {
    8081            rpm = 0.3 + n * 0.2;
    81             n ++;
     82            n++;
    8283        } else if (accel < 0.0 && rpm < 0.3) {
    8384            if (n > 0) {
    8485                rpm = 0.7 + n * 0.1;
    85                 n --;
     86                n--;
    8687            } else
    8788                rpm = 0.2;
     
    133134            bufferlen *= 2;
    134135            byte[] buffer = new byte[bufferlen];
    135             for (int b = 0; b < bufferlen; ) {
     136            for (int b = 0; b < bufferlen;) {
    136137                int j;
    137                 for (j = wavelen / 2; j > 0; j --) {
    138                     buffer[b ++] = (byte) (value >> 8);
    139                     buffer[b ++] = (byte) (value & 0xff);
     138                for (j = wavelen / 2; j > 0; j--) {
     139                    buffer[b++] = (byte) (value >> 8);
     140                    buffer[b++] = (byte) (value & 0xff);
    140141                }
    141142                value = 0x10000 - value;
    142                 for (j = wavelen - wavelen / 2; j > 0; j --) {
    143                     buffer[b ++] = (byte) (value >> 8);
    144                     buffer[b ++] = (byte) (value & 0xff);
     143                for (j = wavelen - wavelen / 2; j > 0; j--) {
     144                    buffer[b++] = (byte) (value >> 8);
     145                    buffer[b++] = (byte) (value & 0xff);
    145146                }
    146147                value = 0x10000 - value;
  • applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge/FakeMapView.java

    r32914 r33342  
    11/*
    22 * GPLv2 or 3, Copyright (c) 2010  Andrzej Zaborowski
    3  *
     3 */
     4package wmsturbochallenge;
     5
     6import java.awt.Graphics;
     7import java.awt.Graphics2D;
     8import java.awt.Point;
     9import java.awt.image.BufferedImage;
     10
     11import org.openstreetmap.josm.data.ProjectionBounds;
     12import org.openstreetmap.josm.data.coor.EastNorth;
     13import org.openstreetmap.josm.gui.MapView;
     14
     15/**
    416 * Implements a fake MapView that we can pass to WMSLayer's .paint,
    517 * this will give us two things:
     
    1426 *    this happened and could only guess.
    1527 */
    16 package wmsturbochallenge;
    17 
    18 import java.awt.Graphics;
    19 import java.awt.Graphics2D;
    20 import java.awt.Point;
    21 import java.awt.image.BufferedImage;
    22 
    23 import org.openstreetmap.josm.data.ProjectionBounds;
    24 import org.openstreetmap.josm.data.coor.EastNorth;
    25 import org.openstreetmap.josm.gui.MapView;
    26 
    2728class FakeMapView extends MapView {
    2829    public ProjectionBounds view_bounds;
     
    3637    public double max_east_west;
    3738
    38     public FakeMapView(MapView parent, double scale) {
    39         super(null, null, null); //TODO MapView constructor contains registering listeners and other code, that probably shouldn't be called in fake map view
     39    FakeMapView(MapView parent, double scale) {
     40        // TODO: MapView constructor contains registering listeners and other code, that probably shouldn't be called in fake map view
     41        super(null, null, null);
    4042        this.parent = parent;
    4143        this.scale = scale;
  • applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge/GameWindow.java

    r32914 r33342  
    11/*
    22 * GPLv2 or 3, Copyright (c) 2010  Andrzej Zaborowski
    3  *
    4  * This implements the game logic.
    53 */
    64package wmsturbochallenge;
     
    3836import org.openstreetmap.josm.gui.layer.Layer;
    3937
     38/**
     39 * This implements the game logic.
     40 */
    4041public class GameWindow extends JFrame implements ActionListener {
    4142    public GameWindow(Layer ground) {
     
    4849
    4950        while (s.getScreenSize().width < width * scale ||
    50                 s.getScreenSize().height < height * scale)
    51             scale --;
     51                s.getScreenSize().height < height * scale) {
     52            scale--;
     53        }
    5254        add(panel);
    5355
     
    7981        car_engine.start();
    8082
    81         for (int i = 0; i < maxsprites; i ++)
     83        for (int i = 0; i < maxsprites; i++) {
    8284            sprites[i] = new sprite_pos();
     85        }
    8386
    8487        generate_sky();
     
    120123        public void save_trace() {
    121124            int len = 0;
    122             for (Collection<WayPoint> seg : trackSegs)
     125            for (Collection<WayPoint> seg : trackSegs) {
    123126                len += seg.size();
     127            }
    124128
    125129            /* Don't save traces shorter than 5s */
     
    343347    int frame;
    344348    boolean downloading = false;
     349
    345350    protected void screen_repaint() {
    346351        /* Draw background first */
     
    351356
    352357        /* Messages */
    353         frame ++;
    354         if ((frame & 8) == 0 && downloading)
     358        frame++;
     359        if ((frame & 8) == 0 && downloading) {
    355360            screen.drawImage(loading.getImage(), centre -
    356361                    loading.getIconWidth() / 2, 50, this);
     362        }
    357363
    358364        /* Sprites */
     
    408414        ground.paint(ground_view.graphics, ground_view, null);
    409415
    410         for (int y = (int) (height * horizon + 0.1); y < height; y ++) {
     416        for (int y = (int) (height * horizon + 0.1); y < height; y++) {
    411417            /* Assume a 60 deg vertical Field of View when
    412418             * calculating the distance at given pixel.  */
     
    415421            double lon_off = lon + (dist - cardist) * sin;
    416422
    417             for (int x = 0; x < width; x ++) {
     423            for (int x = 0; x < width; x++) {
    418424                double p_x = dist * (x - centre) / height;
    419425
     
    439445
    440446        int n = (int) (Math.random() * sw * 0.03);
    441         for (int i = 0; i < n; i ++) {
     447        for (int i = 0; i < n; i++) {
    442448            int t = (int) (Math.random() * 5.0);
    443449            int x = (int) (Math.random() *
     
    490496    }
    491497
    492     /* sizes decides how many zoom levels the sprites have.  We
     498    /** sizes decides how many zoom levels the sprites have.  We
    493499     * could do just normal scalling according to distance but
    494500     * that's not what old games did, they had prescaled sprites
    495501     * for the different distances and you could see the feature
    496502     * grow discretely as you approached it.  */
    497     protected final static int sizes = 8;
    498 
    499     protected final static int maxsprites = 32;
     503    protected static final int sizes = 8;
     504
     505    protected static final int maxsprites = 32;
    500506    protected sprite_pos sprites[] = new sprite_pos[maxsprites];
    501507
     
    537543            int sy = cactus[type].getIconHeight();
    538544
    539             sprite_pos pos = sprites[i ++];
     545            sprite_pos pos = sprites[i++];
    540546            pos.dist = dist;
    541547            pos.sprite = cactus[type].getImage();
     
    548554        Arrays.sort(sprites, 0, i);
    549555        for (sprite_pos sprite : sprites)
    550             if (i --> 0)
     556            if (i-- > 0)
    551557                screen.drawImage(sprite.sprite,
    552558                        sprite.x, sprite.y,
     
    556562
    557563        if (splashframe >= 0) {
    558             splashframe ++;
     564            splashframe++;
    559565            if (splashframe >= 8)
    560566                splashframe = -1;
     
    566572            Image image = cactus[type].getImage();
    567573
    568             for (i = 0; i < 50; i ++) {
     574            for (i = 0; i < 50; i++) {
    569575                int x = (int) (Math.random() * sx);
    570576                int y = (int) (Math.random() * sy);
     
    584590
    585591    public boolean no_super_repaint = false;
     592
    586593    protected class GamePanel extends JPanel {
    587594        public GamePanel() {
     
    607614        }
    608615    }
     616
    609617    JPanel panel = new GamePanel();
    610618
     
    631639     */
    632640    protected Timer timer;
     641
    633642    @Override
    634643    public void actionPerformed(ActionEvent e) {
     
    681690            /* Switch vehicle */
    682691            if (key == KeyEvent.VK_V)
    683                 if (current_car ++>= 1)
     692                if (current_car++ >= 1)
    684693                    current_car = 0;
    685694        }
     
    702711        }
    703712    }
     713
    704714    protected FakeMapView ground_view;
    705715}
  • applications/editors/josm/plugins/wms-turbo-challenge2/src/wmsturbochallenge/WMSRacer.java

    r32914 r33342  
    11/*
    22 * GPLv2 or 3, Copyright (c) 2010  Andrzej Zaborowski
    3  *
    4  * This is the main class for the game plugin.
    53 */
    64package wmsturbochallenge;
     
    2624import org.openstreetmap.josm.plugins.PluginInformation;
    2725
     26/**
     27 * This is the main class for the game plugin.
     28 */
    2829public class WMSRacer extends Plugin implements LayerChangeListener, ActiveLayerChangeListener {
    2930    public WMSRacer(PluginInformation info) {
     
    8687             * horizontal scanlines (lines equidistant from
    8788             * camera eye)) */
    88             for (Layer l : frame.mapView.getLayerManager().getLayers())
     89            for (Layer l : frame.mapView.getLayerManager().getLayers()) {
    8990                if (l.isBackgroundLayer()) {
    9091                    groundLayer = l;
     
    9293                    return;
    9394                }
     95            }
    9496
    9597            groundLayer = null;
Note: See TracChangeset for help on using the changeset viewer.