首页 > > 详细

辅导 DPST1091 24T2 - Programming Fundamentals! Assignment 1 - CS Flowers辅导 R语言

DPST1091 24T2 - Programming Fundamentals!

Assignment 1 - CS Flowers

Overview

CS Flower is an action packed turn-based game where you the player, move across the Physics Lawn and cut down all the flowers. However, it's not as easy as it sounds. While you snip away at each of them one by one, the flowers wake up, evolve and retaliate against you. So it is up to you to figure out the best angle of attack against these formidable foes!

Assignment Structure

This assignment will test your ability to create, use and manipulate 2D arrays and structs to solve problems. This will be done through the in-game map that has been implemented as a 2D array of tiles. Each of these tiles are represented by a struct tile , which is outlined below:

struct tile

Purpose:

To store information about the tiles of the map.

Contains:

enum tile_type type

The type of the map tile.

All tile types are found in the enum tile_type definition.

struct flower flower

Represents the enemy flower at this location (if one exists).

struct flower

Purpose:

To store information about a particular enemy flower.

Contains:

enum flower_state state

Represents the state that the enemy flower is in.

The provided enums are quite extensive. Definitions of each are provided below:

enum tile_type

Purpose:

Represent the possible types of a tile.

Possible values:

EMPTY

Represents an empty space.

BUSH

A wall that blocks the movement of the player and enemies.

BRANCH

An interactable object that will create sound when stepped on by the player.

DANGER

A tile that indicates a root will erupt soon.

ROOT

A wall that the enemy can place down.

POLLEN

A tile that kills the player, which the enemy can place down.

SEEDLING

A baby flower that can grow.

FLOWER

An enemy flower.

enum flower_state


Purpose:

Represents the state that the flower is in.

Possible values:

NONE

DORMANT

DISTURBED

AWAKENED

ANXIOUS

ENERGETIC

Game Structure

There are two main phases to the overall game:

Setup Phase

This phase takes care of the initial setup of the map and the game. The setup is as follows:

1. The player is spawned onto the map

2. Various tiles known as foliage are placed onto the map

3. The flowers which act as enemies are spawned onto the map

Gameplay Phase

This phase handles the gameplay, which is split into turns. On each turn, the player, flowers, and the game will manipulate the map. A turn is comprised of the following steps:

1. The Player Step

The player is allowed to make an action like moving around or cutting a flower

2. The Upkeep Step

The upkeep is an intermediary step where you update parts of the map and its tiles

3. The Flower Step

The flowers are all allowed to make an action like attacking or defending against the player

4. The End Step

The final step at the end of a turn in which you determine if the game should end or continue

As you progress through each stage of this assignment, you will be implementing parts of each step.

How To Get Started

In order to get started with CS Flowers, do the following:

1. Create a new folder for your assignment work and move into it.

$ mkdir ass1

$ cd ass1

2. Download the starter code (cs_flowers.c) here or, copy this code to your CSE account using the following command

$ 1091 fetch_activity cs_flowers

1. Run 1091 autotest cs_flowers to make sure you have correctly downloaded the file.

$ 1091 autotest cs_flowers

NOTE:

When running the autotest on the starter code (with no modifications), it is expected to see failed tests. You can use [ctrl + c] to exit the autotests.

1. Read through Stage 1.

2. Spend a few minutes playing with the reference solution -- get a feel for how the assignment works.

$ 1091 cs_flowers

3. Think about your solution, draw some diagrams, write some pseudocode to help you get started.

HINT:

You might also find it helpful to draw diagrams and write pseudocode in later stages, especially stage 3 and stage 4!

1. Start coding!

Reference Solution

To help you understand the proper behaviour of the game, we have provided a reference implementation. If you have any questions about the behaviour of your assignment, you can check by trying it in the reference implementation.

To run the reference implementation, use the following command:

$ 1091 cs_flowers

About the Starter Code

The provided starter code has done some setup for you. This is explained below.

Before the main function, the starter code has:

1. Imported the standard input/output library.

2. Defined some initial #define 's and enums.

3. Defined the struct(s) described above.

In the main function, the starter code:

1. Creates a 2D array of struct tile s called map .

2. Initialises this map with some default values.

3. Prompts you to write your own code!

HINT:

To start with, feel free to write your code in the main function! You can also add in your own functions as you go - we would definitely recommend this :D





联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!