🗡️Building the thing
What I'll do here is create for you multiple checklists, that corresponds to different part of the project and that you can follow in order to build it. All the code for my "FdF" is available on my Github. If you have any question on it, don't hesitate to contact me (Laura) and it would be a pleasure for me to answer all the questions you might have.
To realize FdF I created 6 .c
files:
fdf.c
: the place where themain
is located, error handling and memory allocationstart.c
: the place where I initialize my graphic variables and where I do preliminary checkspoints.c
: the place where I create my three and two dimensional point tableslimits.c
: the place where I define which point should connect to another pointdraw.c
: this is where I have all my formulas and functions that allow me to draw what I wanthooks.c
: the place where I give instructions to interact with the mouse and keyboard
and of course a .h
called "fdf.h
" where I have the most important and biggest structure.
We'll go through all these files via checklists so you can see what logic I applied.
There must be NO leaks. Check that you free the allocated memory each time !
Of course you can do otherwise than what I have shown you above. Here is a more global checklist to make the project your own and make it the best you can.
I didn't put everything otherwise it will not be understandable ^^ I hope it will be useful...
(some) Checklists
Main Checklist
Map Checklist
Graphical Programmation Checklist
Initialize the display, the window and the image
Initialize the infinite loop for your graphic environment
fdf.c
I created three functions in this file.
One that handles errors (simply exit the program and display a message when called), one that frees the tables that I don't need any more and a main that can be defined by these tasks:
points.c
This file is very simple. It simply initializes my array with three-dimensional points (x,y,z) and another array with two-dimensional points (x,y) that I create from the three-dimensional points.
From the the data stored in start.c (the map data), i created a single list with all 3D points
From the list containing all 3D points I created another single list with all 2D points
Check that you use the correct formula to convert your points
hooks Checklist
The window and the program should close properly when...
You click on ESC
You close the window by clicking on the cross
FdF BONUS
When you use the mouse cursor downwards you zoom the image
When you use the mouse cursor upwards you zoom out the image
When you press w,a,s,d (or the arrows) you can move
When you click on another key you can rotate (change the angle of the image)
Add another bonus you like
I hope this helps! Let me know if you have any other questions.
Last updated