<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Excerpt | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/category/excerpt/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Wed, 01 Jul 2020 19:36:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>Excerpt | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>Thrusting in different directions</title>
		<link>https://learncgames.com/thrusting-in-different-directions/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=thrusting-in-different-directions</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 06 Jul 2020 23:00:06 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Ebook]]></category>
		<category><![CDATA[Excerpt]]></category>
		<category><![CDATA[angles]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=945</guid>

					<description><![CDATA[<p>When you press the control key, the player&#8217;s ship will accelerate in whatever direction (0-23) it is facing. To make this possible, I pre-populated a couple of float arrays with values x and y for thrust in any of the 24 directions. This function populate the two arrays. These are declared as float thrustx[24]; float [&#8230;]</p>
The post <a href="https://learncgames.com/thrusting-in-different-directions/">Thrusting in different directions</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:636,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/dognamedseven-1619308\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1034657&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:637,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1034657&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 17:03:33&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-09 22:43:15&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-21 05:41:42&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-31 00:00:18&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-03 19:46:00&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-08 06:34:22&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-12 09:32:39&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-16 11:11:02&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-20 08:07:59&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-20 08:07:59&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_948" aria-describedby="caption-attachment-948" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-948" src="https://learncgames.com/wp-content/uploads/2020/07/math-1034657_640-300x284.png" alt="Trigonometry" width="300" height="284" srcset="https://learncgames.com/wp-content/uploads/2020/07/math-1034657_640-300x284.png 300w, https://learncgames.com/wp-content/uploads/2020/07/math-1034657_640.png 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-948" class="wp-caption-text">Image by <a href="https://pixabay.com/users/dognamedseven-1619308/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1034657">dognamedseven</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=1034657">Pixabay</a></figcaption></figure>
<p>When you press the control key, the player&#8217;s ship will accelerate in whatever direction (0-23) it is facing. To make this possible, I pre-populated a couple of float arrays with values x and y for thrust in any of the 24 directions.</p>
<p>This function populate the two arrays. These are declared as</p>
<pre><code class="language-c" data-line="">float thrustx[24];
float thrusty[24];

void InitThrustAngles() {
    const float pi = 3.14159265f;
    const float degreeToRad = pi / 180.0f;
    float degree = 0.0f;
    for (int i = 0; i&lt;24; i++) {
        float radianValue = degree * degreeToRad;
        thrustx[i] = (float)sin(radianValue);
        thrusty[i] = (float)-cos(radianValue);
        degree += 15;
    }
}</code></pre>
<p>It uses trigonometry to calculate the horizontal and vertical amounts for any of the angles 0,15,30..345 degrees. As sin and cos functions work in radians rather than degrees, the variable radianValue is calculated from the degree angle by multiplying by the value degreesToRad. If you remember your school trigonometry, one radian = 180/pi degrees. So the code divides by this value (or multiplies by its inverse in this case).</p>
<p>Then when you press the control key, it just adds the appropriate thrustx and thrusty value to the vx and vy variables. Simple and fast.</p>
<p>&nbsp;</p>The post <a href="https://learncgames.com/thrusting-in-different-directions/">Thrusting in different directions</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">945</post-id>	</item>
		<item>
		<title>How to find files in Ubuntu</title>
		<link>https://learncgames.com/how-to-find-files-in-ubuntu/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-find-files-in-ubuntu</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Mon, 29 Jun 2020 23:00:17 +0000</pubDate>
				<category><![CDATA[Excerpt]]></category>
		<category><![CDATA[SDL]]></category>
		<category><![CDATA[Techniques]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=895</guid>

					<description><![CDATA[<p>In this I&#8217;m looking for the SDL2 header files. These are installed when you install libsdl2-dev as we saw yesterday. While you can do it from a terminal with the find command, I find it easier to do it from the GUI. We need the Files utility which you get by clicking on this icon [&#8230;]</p>
The post <a href="https://learncgames.com/how-to-find-files-in-ubuntu/">How to find files in Ubuntu</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<p>In this I&#8217;m looking for the SDL2 header files. These are installed when you install libsdl2-dev as we saw yesterday.</p>
<p>While you can do it from a terminal with the find command, I find it easier to do it from the GUI. We need the Files utility which you get by clicking on this icon on the left toolbar. <img decoding="async" class="alignleft size-full wp-image-896" src="https://learncgames.com/wp-content/uploads/2020/06/files..png" alt="files-icon" width="38" height="41" /> Now click Other Locations on the left and you should see something like this.</p>
<p><img decoding="async" class="alignleft size-medium wp-image-897" src="https://learncgames.com/wp-content/uploads/2020/06/PnThisComputer-300x53.png" alt="On This computer" width="300" height="53" srcset="https://learncgames.com/wp-content/uploads/2020/06/PnThisComputer-300x53.png 300w, https://learncgames.com/wp-content/uploads/2020/06/PnThisComputer.png 686w" sizes="(max-width: 300px) 100vw, 300px" /><br />
Click Computer. This will let you search through the entire Linux file tree.</p>
<p>Click on the magnifying glass icon and in the text box that appears type in sdl2 and press enter. It will spend a few seconds or minutes searching and then find a number of files/folders.</p>
<p>The first result was SDL2 and the <strong><em>usr/include</em></strong> is a big clue. Double-click on this and it will open on a folder full of header files!That&#8217;s what we want.<img loading="lazy" decoding="async" class="alignleft size-medium wp-image-898" src="https://learncgames.com/wp-content/uploads/2020/06/SDL2-folder-300x25.png" alt="SDL2 Folder" width="300" height="25" srcset="https://learncgames.com/wp-content/uploads/2020/06/SDL2-folder-300x25.png 300w, https://learncgames.com/wp-content/uploads/2020/06/SDL2-folder.png 518w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>&nbsp;</p>
<p>When you are configuring gcc/clang and want to add paths for include files like SDL2, it&#8217;s important to know where those files are located.</p>The post <a href="https://learncgames.com/how-to-find-files-in-ubuntu/">How to find files in Ubuntu</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">895</post-id>	</item>
	</channel>
</rss>
