Fishtank
Public Member Functions | List of all members
Fish Class Reference

Represents the position and velocity of a Shape on an infinite x-y grid. More...

#include <fish.h>

Public Member Functions

 Fish (Shape shape, int col, int row, int horizontal_speed, int vertical_speed)
 
int col () const
 
int row () const
 
int width () const
 
int height () const
 
void tick ()
 Update col using horizontal_speed. Update row using vertical_speed. More...
 
void draw (Screen *screen) const
 Render to the given Screen. Draws over whatever is already there with no concept of transparency. More...
 

Detailed Description

Represents the position and velocity of a Shape on an infinite x-y grid.

Definition at line 9 of file fish.h.

Constructor & Destructor Documentation

◆ Fish()

Fish::Fish ( Shape  shape,
int  col,
int  row,
int  horizontal_speed,
int  vertical_speed 
)
explicit

Construct a Fish at a given position and with the given velocity.

Parameters
shapethe fish drawing
colcan be positive or negative
rowcan be positive or negative
horizontal_speedcan be positive or negative
vertical_speedcan be positive or negative

Definition at line 7 of file fish.cpp.

Member Function Documentation

◆ col()

int Fish::col ( ) const
Returns
column (x-coordinate) of the top left character

Definition at line 12 of file fish.cpp.

◆ draw()

void Fish::draw ( Screen screen) const

Render to the given Screen. Draws over whatever is already there with no concept of transparency.

Because Fish::col and Fish::row return unwrapped coordinates, Fish::draw wraps them to the dimensions of the Screen.

Definition at line 35 of file fish.cpp.

◆ height()

int Fish::height ( ) const
Returns
height of the grid of characters

Definition at line 18 of file fish.cpp.

◆ row()

int Fish::row ( ) const
Returns
row (y-coordinate) of the top left character

Definition at line 14 of file fish.cpp.

◆ tick()

void Fish::tick ( )

Update col using horizontal_speed. Update row using vertical_speed.

Definition at line 20 of file fish.cpp.

◆ width()

int Fish::width ( ) const
Returns
width of the grid of characters

Definition at line 16 of file fish.cpp.


The documentation for this class was generated from the following files: