diff options
author | Crystal <crystal@wizard.tower> | 2024-02-15 00:09:19 +0100 |
---|---|---|
committer | Crystal <crystal@wizard.tower> | 2024-02-15 00:09:19 +0100 |
commit | 191585eb38518d0b35e8f60bcdee49a4962ca257 (patch) | |
tree | 4afeec358bf1886b61e9b5d1c3e518cdb22649e1 | |
parent | 0191c68db777447883bf2c78014448a139a19e81 (diff) | |
download | www-191585eb38518d0b35e8f60bcdee49a4962ca257.tar.gz |
Add stuff
-rw-r--r-- | blog/c/game.html | 17 | ||||
-rwxr-xr-x | src/css/style.css | 7 | ||||
-rw-r--r-- | src/org/blog/c/game.org | 7 |
3 files changed, 14 insertions, 17 deletions
diff --git a/blog/c/game.html b/blog/c/game.html index ac14ee3..6543e5a 100644 --- a/blog/c/game.html +++ b/blog/c/game.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> -<!-- 2024-02-15 Thu 00:02 --> +<!-- 2024-02-15 Thu 00:09 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>The loneliness Game</title> @@ -23,17 +23,17 @@ <p> 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! </p> -<div id="outline-container-org09f9ff1" class="outline-2"> -<h2 id="org09f9ff1">The concept :</h2> -<div class="outline-text-2" id="text-org09f9ff1"> +<div id="outline-container-orgbfcec8f" class="outline-2"> +<h2 id="orgbfcec8f">The concept :</h2> +<div class="outline-text-2" id="text-orgbfcec8f"> <p> Basically the player is faced with a NxM field made up with the sign <b>“-”</b> and the player is denoted by the symbol <b>“+”</b>, there are also Bonuses <b>“B”</b> which add 1 to your score, Traps <b>“T”</b>, that remove one from your score, and Dead <b>“D”</b> 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. </p> </div> </div> -<div id="outline-container-org82bcd1e" class="outline-2"> -<h2 id="org82bcd1e">The code :</h2> -<div class="outline-text-2" id="text-org82bcd1e"> +<div id="outline-container-org7a1e154" class="outline-2"> +<h2 id="org7a1e154">The code :</h2> +<div class="outline-text-2" id="text-org7a1e154"> <div class="org-src-container"> <pre class="src src-c"><span class="linenr"> 1: </span><span style="color: #f9e2af;">#include</span> <span style="color: #f38ba8;"><</span><span style="color: #a6e3a1;">stdio.h</span><span style="color: #f38ba8;">></span> <span class="linenr"> 2: </span><span style="color: #f9e2af;">#include</span> <span style="color: #f38ba8;"><</span><span style="color: #a6e3a1;">stdlib.h</span><span style="color: #f38ba8;">></span> @@ -234,7 +234,6 @@ We show the score and the moves too, which at the start of the game are set to 0 <p> After that we have some logic which should also be changed to account for the n and m changes yet again </p> - <div class="org-src-container"> <pre class="src src-c"><span class="linenr">37: </span> <span style="color: #cba6f7;">if</span> <span style="color: #f38ba8;">(</span>input == <span style="color: #a6e3a1;">'w'</span><span style="color: #f38ba8;">)</span> <span style="color: #f38ba8;">{</span> <span class="linenr">38: </span> printf<span style="color: #fab387;">(</span><span style="color: #a6e3a1;">"Moving up\n"</span><span style="color: #fab387;">)</span>; @@ -289,7 +288,7 @@ What this achieves is the “teleportation effect” whenever you are at </div> <div id="postamble" class="status"> <p class="author">Author: Crystal</p> -<p class="date">Created: 2024-02-15 Thu 00:02</p> +<p class="date">Created: 2024-02-15 Thu 00:09</p> </div> </body> </html> diff --git a/src/css/style.css b/src/css/style.css index d76b1a6..6f611e8 100755 --- a/src/css/style.css +++ b/src/css/style.css @@ -16,7 +16,12 @@ html { max-width: 70em; margin: auto; } - +.src-c { + background-color: #9e9795; + word-wrap: break-word; + white-space: -moz-pre-wrap; + white-space: pre-wrap; +} h1 { color: var(--color1); text-align: center; diff --git a/src/org/blog/c/game.org b/src/org/blog/c/game.org index 6b0478c..3ed154e 100644 --- a/src/org/blog/c/game.org +++ b/src/org/blog/c/game.org @@ -19,8 +19,6 @@ Hello !!, I hope you are doing great you amazing person whoever you are, and I r 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 : -#+ATTR_HTML: :style background-color:#e2d8d6; - #+BEGIN_SRC c -n #include <stdio.h> #include <stdlib.h> @@ -165,7 +163,6 @@ char input,map[n][m]={'-'}; For now at least, n and m are hardcoded to 5, but this will change later. Of course we have the usual inits on line 11, though since we are using variables instead of hardcoding 5, we will have to find the center by ourselves - #+ATTR_HTML: :style background-color:#e2d8d6; #+BEGIN_SRC c -n 11 int stop=0,i=0,moves=0,score=0,pos[2] = {n/2,m/2}; #+END_SRC @@ -174,7 +171,6 @@ This is getting better, of course we then initialize the coordinates of bonus, t Here comes the line 17-21, where it generates a random coordinate for the aforementioned pickups, and do that until there is no conflict between eachother and the player) here we will need to change it a tiny bit. - #+ATTR_HTML: :style background-color:#e2d8d6; #+BEGIN_SRC c -n 17 bonus[0] = arc4random_uniform(n); bonus[1] = arc4random_uniform(m); trap[0] = arc4random_uniform(n); trap[1] = arc4random_uniform(m); @@ -185,7 +181,6 @@ Looking good so far!!, We then have line 21-23 which also shows the pickups as t The main interactive program starts here, which will learn at least one time and stop if the received input is a *'c'*, it starts with a nested for loop on line 26 up to 31 to show the content of the map, nothing fancy, just some matrix stuff. we need to change the 5 though! - #+ATTR_HTML: :style background-color:#e2d8d6; #+BEGIN_SRC c -n 26 for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { @@ -198,8 +193,6 @@ The main interactive program starts here, which will learn at least one time and We show the score and the moves too, which at the start of the game are set to 0. and we prompt the user for a direction. Note here the space before the %c, this basically allows for the program to not choke on newlines and also even if the user writes multiple keys at the same time, they will still be done, like *ww* will make the player move twice up. After that we have some logic which should also be changed to account for the n and m changes yet again - -#+ATTR_HTML: :style background-color:#e2d8d6; #+BEGIN_SRC c -n 37 if (input == 'w') { printf("Moving up\n"); |