Skip to content

Commit

Permalink
Simplify call sites to Draw
Browse files Browse the repository at this point in the history
They were always equivalent to `mvprintw`, so do that.
  • Loading branch information
noncombatant committed May 14, 2023
1 parent 956c7ef commit 87dfd37
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions non_kitten_items.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ static const char* Messages[] = {
"It is a marzipan dreadnought that appears to have melted and stuck.",
"It is an ancient mariner, and he stoppeth one of three.",
"It is a set of wind-up chatter teeth.",
"It is -- I just feel something wonderful is about to happen.",
"It pleases you to be kind to what appears to be kitten -- but it’s not!",
"It is I just feel something wonderful is about to happen.",
"It pleases you to be kind to what appears to be kitten but it’s not!",
"It’s 1000 secrets the government doesn’t want you to know!",
"It’s a banana! Oh, joy!",
"It’s a battery-powered brass lantern.",
Expand Down
10 changes: 1 addition & 9 deletions robotfindskitten.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,8 @@ static void InitializeGame(size_t item_count) {
}
}

// TODO: Remove this and just use printw (and in some cases, mvprintw).
static void Draw(const ScreenObject* o) {
printw("%s", o->icon);
mvprintw(o->y, o->x, "%s", o->icon);
}

static void ShowMessage(const char* message) {
Expand Down Expand Up @@ -323,7 +322,6 @@ static void RedrawScreen(void) {
attroff(attributes);
}
for (size_t i = 0; i < GameState.item_count; ++i) {
move(GameState.items[i].y, GameState.items[i].x);
Draw(&GameState.items[i]);
}
move(GameState.items[Robot].y, GameState.items[Robot].x);
Expand Down Expand Up @@ -385,10 +383,8 @@ static void PlayAnimation(bool approach_from_right) {
printf("\a");

GameState.items[Robot].icon = " ";
move(GameState.items[Robot].y, GameState.items[Robot].x);
Draw(&GameState.items[Robot]);
GameState.items[Kitten].icon = " ";
move(GameState.items[Kitten].y, GameState.items[Kitten].x);
Draw(&GameState.items[Kitten]);

GameState.items[Robot].icon = "🤖";
Expand All @@ -403,14 +399,10 @@ static void PlayAnimation(bool approach_from_right) {
GameState.items[Kitten].x = animation_meet + i;
}

move(kitten.y, kitten.x);
Draw(&kitten);
move(robot.y, robot.x);
Draw(&robot);

move(GameState.items[Robot].y, GameState.items[Robot].x);
Draw(&GameState.items[Robot]);
move(GameState.items[Kitten].y, GameState.items[Kitten].x);
Draw(&GameState.items[Kitten]);
move(GameState.items[Robot].y, GameState.items[Robot].x);
refresh();
Expand Down

0 comments on commit 87dfd37

Please sign in to comment.