Random Weather Events - UQdeco2800/2022-studio-3 GitHub Wiki

Overview

Weather icon will be displayed randomly at the start of the game and can randomly change to a different icon after x minutes, weather icon should not be appeared two times in a row. Along with the changing of the weather icon, the weather visual filter will also be applied to change the look of the game. The movement of the unit will also be affected (ie. slow down) depending on the weather effect.

Displaying the weather icon and timer

Usage

Setting the layout for weather icon and timer, to adjust the icon and timer bigger or smaller or change the position of it, change value in setSize() and setPosition() to desired choice. The default for now is on the top middle.

  public void layout() {
        public void layout() {
        //  Layout for weatherFilter
        weatherFilter.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
        weatherFilter.setPosition(0,0);

        //  Layout for weatherImage
        weatherImage.setSize(75f, 75f);
        weatherImage.setPosition(Gdx.graphics.getWidth()/2f-weatherImage.getWidth()/2f, Gdx.graphics.getHeight()-85f);

        //  Layout for timer
        this.timerLabel.setAlignment(Align.left);
        this.timerLabel.setWrap(true);
        this.timerLabel.setSize(3f,3f);
        this.timerLabel.setPosition(Gdx.graphics.getWidth()/2f + weatherImage.getWidth()/2f + 15f, Gdx.graphics.getHeight()-50f);
    }

Code for all the implementation can found here

WeatherIcon

WeatherIconDisplay

UML model