The loneliness Game
Hello !!, I hope you are doing great you amazing person whoever you are, and I really appreciate you reading my little C programming adventure. Soo basically I wanted to blog about a little game I made when bored, and figured out it would be a great way to optimize it, and learn new stuff too by documenting the process!
The concept :
Basically the player is faced with a NxM field made up with the sign “-” and the player is denoted by the symbol “+”, there are also Bonuses “B” which add 1 to your score, Traps “T”, that remove one from your score, and Dead “D” which resets the score to 0. I will go into more of the specifics later but for now this is how it works, and the controls are Basic WASD bindings, though i may go for a HJKL style later.
The code :
1: #include <stdio.h> 2: #include <stdlib.h> 3: int main(int argc, char *argv[]) { 4: char input,map[5][5] = { 5: {'-', '-', '-', '-', '-'}, 6: {'-', '-', '-', '-', '-'}, 7: {'-', '-', '-', '-', '-'}, 8: {'-', '-', '-', '-', '-'}, 9: {'-', '-', '-', '-', '-'} 10: }; 11: int stop=0,i=0,moves=0,score=0,pos[2<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <!-- 2023-11-01 Wed 20:17 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>ALSD1</title> <meta name="author" content="Crystal" /> <meta name="generator" content="Org Mode" /> <link rel="stylesheet" type="text/css" href="../src/css/colors.css"/> <link rel="stylesheet" type="text/css" href="../src/css/style.css"/> <link rel="icon" type="image/x-icon" href="https://crystal.tilde.institute/favicon.png"> </head> <body> <div id="org-div-home-and-up"> <a accesskey="h" href="../../../uni_notes/"> UP </a> | <a accesskey="H" href="https://crystal.tilde.institute/"> HOME </a> </div><div id="content" class="content"> <h1 class="title">ALSD1</h1> <div id="table-of-contents" role="doc-toc"> <h2>Table of Contents</h2> <div id="text-table-of-contents" role="doc-toc"> <ul> <li><a href="#org99d5220">Contenu de la Matiére</a> <ul> <li><a href="#orgbd002d7">Chapitre 1: Elements de Base</a></li> <li><a href="#orgeb962fb">Chapitre 2: Présentation du formalisme Algorithmique</a></li> <li><a href="#org7a1fb51">Chapitre 3: Eléments de base du language C</a></li> <li><a href="#org5f789aa">Chapitre 4: Modularité( Fonction et Procédure )</a></li> <li><a href="#org330830d">Chapitre 5: Les structures des données statiques</a></li> </ul> </li> <li><a href="#orgced3d78">Premier cours : Algorithmes <i>Oct 1</i> :</a> <ul> <li><a href="#orga9ff303">Définition d’un algorithm :</a> <ul> <li><a href="#org38de9fd">Example d’un Algo : Résolution d’une équation du second ordre (ax²+bx+c=0)</a></li> </ul> </li> </ul> </li> </ul> </div> </div> <div id="outline-container-org99d5220" class="outline-2"> <h2 id="org99d5220">Contenu de la Matiére</h2> <div class="outline-text-2" id="text-org99d5220"> </div> <div id="outline-container-orgbd002d7" class="outline-3"> <h3 id="orgbd002d7">Chapitre 1: Elements de Base</h3> <div class="outline-text-3" id="text-orgbd002d7"> <ul class="org-ul"> <li>Algorithmique, procésseur, action.<br /></li> <li>Programme et languages de programmation.<br /></li> <li>Analyse des problémes.<br /></li> </ul> </div> </div> <div id="outline-container-orgeb962fb" class="outline-3"> <h3 id="orgeb962fb">Chapitre 2: Présentation du formalisme Algorithmique</h3> </div> <div id="outline-container-org7a1fb51" class="outline-3"> <h3 id="org7a1fb51">Chapitre 3: Eléments de base du language C</h3> </div> <div id="outline-container-org5f789aa" class="outline-3"> <h3 id="org5f789aa">Chapitre 4: Modularité( Fonction et Procédure )</h3> </div> <div id="outline-container-org330830d" class="outline-3"> <h3 id="org330830d">Chapitre 5: Les structures des données statiques</h3> </div> </div> <div id="outline-container-orgced3d78" class="outline-2"> <h2 id="orgced3d78">Premier cours : Algorithmes <i>Oct 1</i> :</h2> <div class="outline-text-2" id="text-orgced3d78"> </div> <div id="outline-container-orga9ff303" class="outline-3"> <h3 id="orga9ff303">Définition d’un algorithm :</h3> <div class="outline-text-3" id="text-orga9ff303"> <p> Un ensemble d’opérations ecrites dans le language naturel.<br /> </p> </div> <div id="outline-container-org38de9fd" class="outline-4"> <h4 id="org38de9fd">Example d’un Algo : Résolution d’une équation du second ordre (ax²+bx+c=0)</h4> <div class="outline-text-4" id="text-org38de9fd"> <ol class="org-ol"> <li>Si a=0 ET b=0 alors <b>l’équation n’est pas du 2nd ordre</b>.<br /></li> <li>Si a=0 et b≠0 alors <b>x= -c/5</b> .<br /></li> <li>Si a≠0 alors <b>calculer Δ= b²-4ac</b> :<br /> <ol class="org-ol"> <li>Si Δ=0 alors <b>x=-b/2a</b>.<br /></li> <li>Si Δ<0 alors <b>l’équation n’as pas de solution</b>.<br /></li> <li>Si Δ>0 alors <b>x=[-b±sqrt(Δ)]/2a</b><br /></li> </ol></li> </ol> </div> </div> </div> </div> </div> <div id="postamble" class="status"> <p class="author">Author: Crystal</p> <p class="date">Created: 2023-11-01 Wed 20:17</p> </div> </body> </html>