fantaye-1 / man_pac Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
After testing 9f2a567, attempting to restore original functionality with restore()
resulted in an irrecoverable error in the kernel that required a hard restart. This only occurs when terminating after the last ghost is registered as terminating, konami.c:270.
Consider these data types for the implementation in ghost.c
:
// Represents a coordinate pair
typedef struct {
int x;
int y;
} coord_t;
// Represents a width/height pair
typedef struct {
int w;
int h;
} dims_t;
// Represents a ghost
typedef struct {
pid_t pid; // Ghost process ID
coord_t pos; // Pixel-based position of Ghost
dims_t dims; //
int order; // Order in which a Ghost was instantiated (first = 0, second = 1, etc.)
} ghost_t;
Each ghost:
screen
width and heightComplete this functions in ghost.c
to be used later:
// Returns the next position for a ghost
coord_t
next_position(ghost_t *ghost, dims_t *screen)
{
coord_t new_pos = {.x = 0, .y = 0};
return new_pos;
}
There is duplicated code between ghost.c
and manpac.c
.
To reduce our line count, we should refactor the shared code into a shared.c
file, add the function protoypes to shared.h
.
The original behavior should be maintained.
Use @yashito's next movement code to determine a ghost's next position given a timer of some sub-second interval.
Must accept keyboard input at a global scope without a window.
Movement should be proportional to Ghost's movement.
Intercept key events at the kernel level to check for the Konami code.
This is not a keylogger, it should only store the state necessary to check the. Storing only the previous character and a boolean valid state should be sufficient.
When manpac process was executed, it created about 120 idle processes of manpac, even after it supposed to be terminated.
Review shared.h
. Note the structures coord_t
and dims_t
which are used to represent the location and dimensions of a ghost (ghost_t
).
Complete the following function in manpac.c
, it will return NULL
when there is no collision, otherwise it returns the first Ghost which collides with Manpac:
ghost_t*
collided_ghost() {
ghost_t *ghost = NULL;
int i;
for (i = 0; i < 4; i++)
{
ghost = &shared->ghosts[i];
}
}
Update the list of ghosts at an interval you think makes sense. This should be done in manpac.c
, not a new file. Using the order
of a ghost, assign a color that will be used to identify the ghost.
List the PID of the ghost in that color.
You can use ANSI escape codes to color text, like this:
#include <stdio.h>
#define RED "\x1B[31m"
#define GRN "\x1B[32m"
#define YEL "\x1B[33m"
#define BLU "\x1B[34m"
#define MAG "\x1B[35m"
#define CYN "\x1B[36m"
#define WHT "\x1B[37m"
#define RESET "\x1B[0m"
void main(int argc, char **argv) {
printf(RED "red text" RESET "\n");
}
A good starting point for your implementation:
https://github.com/fantaye-1/man_pac/blob/master/manpac.c#L131
Setup:
Wraps exec system call to replace calls of "/usr/bin/man" "man pac".
The GUI implementation using GTK.
The windows will be created for each Manpac and the Ghosts that moves.
It describes:
It should explain how to:
When called properly, spawns "ghost" executable
Using the kernel file descriptor for "/proc", wrap the implementation of readdir
so that instances of ghost
are not visible.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.