tag:blogger.com,1999:blog-22236505679186899772024-03-19T14:14:19.719-07:00Random Tuts :)XNA and c# Game development Tutorials for android, xbox, windows, iosAnonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comBlogger31125tag:blogger.com,1999:blog-2223650567918689977.post-21025727248308514662016-07-07T13:58:00.002-07:002016-07-07T13:58:58.573-07:00Unity: mecanim crouching crouch with colliders tutorial Unity: mecanim crouching crouch with colliders tutorial
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/Gha5BFBS-qs" width="480"></iframe><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-15168914134841852682016-07-07T13:53:00.002-07:002016-07-07T13:56:29.214-07:00Unity 3D - Mecanim Root motion basic movement tutorialUnity 3D - Mecanim Root motion basic movement tutorial<br />
<br />
<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/embed/N4pc1Ov-VO0" width="400"></iframe><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-51707280192018329272014-06-25T21:47:00.000-07:002014-06-25T21:47:39.247-07:00II. Calling a new Activity AndroidTo start a new activity in android, we use the intent class.<br />
<br />
For example. We have a button that executes a method switchScreen(View view) when clicked.<br />
<br />
on switchScreen(View view), we are going to start a new activity.<br />
It should look something like this.<br />
<br />
public void switchScreen(View view)<br />
{<br />
Intent intent = new Intent(this, SecondActivity.class); //Creates a new instance of SecondActivity<br />
startActivity(intent);//Starts the intent<br />
<br />
//NOTE: To use Intent class, we must import the intent. Simple click F2 with the intent and import it.<br />
//Or in Eclipse, press shift +o to import missing packages.<br />
}<br />
<br />
putting few content with the content.<br />
<br />
When starting intents, we can send some values with it.<br />
This values can be fetch on the SecondActivityClass..<br />
<br />
To put some values with the intent, we are going to use PutExtra.<br />
<br />
Intent intent = new Intent(this, SecondActivity.class); //Creates a new instance of SecondActivity<br />
//intent.putExtra("key","value"); key is the name of the holder. for example categorid, value is value itself. ex: 1065<br />
intent.putExtra("categoryid", "1065"); //set an extra message or value with the intent.<br />
startActivity(intent);//Starts the intent<br />
<br />
<br />
To fetch the values of the intent. We are going to fetch it with the OnCreate method of the SecondActivity.java<br />
<br />
Here's the syntax.<br />
Bundle bundle = new Bundle();<br />
Intent FirstClassIntent = getIntent();<br />
bundle = FirstClassIntent.GetExtra();<br />
<br />
String catid = bundle.getString("categoryid");<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-6435614020232040732014-06-25T21:35:00.000-07:002014-06-25T21:35:42.761-07:00I. Getting Started with Android Development<br />
First of all, there are several IDE that can help you develop Android Applications(Eclipse, maven etc).<br />
<br />
IDE makes it easier for us to create and develop mobile, web or platform-specific applications.<br />
<br />
I'll be using Eclipse for all tutorials, so it would be easier for you if you also use eclipse.<br />
Click here to download eclipse with ADT.<br />
<br />
You should also have Java sdk/jdk in your machine.<br />
You can download it here.<br />
<br />
Basically, we're going to use the native language of android OS which is JAVA.<br />
For designs or the front part of the applications, we can design it with the IDE that generates XML codes for each item or attributes.<br />
<br />
<br />
Now let me discuss the structure of a simple android project.<br />
Res - contains layout, strings and values used for the front part of the App.<br />
Src - contains .java files used for functionalities of the App.<br />
<br />
Under res folder, there are many files in it. such as string.xml, layout folder etc.<br />
string.xml are collection of strings that can be reference and used for pre-defined or constant string of the application. One example of it's usage is when assigning a value of an EditText(Textbox of Android).<br />
Instead of hard-coding it. you can easily refer to it using its name in the string.xml.<br />
It makes revision easier for us, for example. we have a<br />
<span style="color: #e06666;"><string name="ApplicationName">My Example App</string></span><br />
instead of type My Example app for every activities we create, we can easily Refer to it using @string/ApplicationName. If ever we change the content of the ApplicationName, it will also change the value of all the item or object that refers to it. We don't have to search for all the hard-coded text and replace it.<br />
<br />
Layout folder contains layoutname.xml that are used as the graphical user interface of an activity.<br />
Here we store different layouts that can be called at the source file setContentView(R.layout.layoutname).<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-91117283077914560312014-03-04T15:05:00.002-08:002014-03-04T15:08:10.562-08:00Simple Database Module[VB.NET]<div style="text-align: center;">
VB.NET + ACCESS version of simple database module</div>
<div style="text-align: center;">
Create a new module in your Project[can be found @ solution explorer]</div>
<div style="text-align: center;">
[Right Click > add > Module]</div>
<br />
<span style="color: #6fa8dc;">Imports System.Data.OleDb<br /><br />Module dCon<br /> Dim con As OleDbConnection<br /> Dim da As OleDbDataAdapter<br /> Dim dt As DataTable<br /><br /> Public Sub loadConnection(ByVal conStr As String)<br /> con = New OleDbConnection(conStr)<br /> con.Open()<br /> If (con.State = ConnectionState.Open) Then<br /> MessageBox.Show("Connection was Established")<br /> End If<br /> End Sub<br /> Public Sub execute(ByVal sql As String)<br /> If (con.State = ConnectionState.Open) Then<br /> dt = New DataTable<br /> da = New OleDbDataAdapter(sql, con)<br /> da.Fill(dt)<br /> Else<br /> 'load connection<br /> End If<br /> End Sub<br /> Public Sub setUpListView(ByVal _lv As ListView)<br /> _lv.FullRowSelect = True<br /> _lv.GridLines = True<br /> _lv.View = View.Details<br /><br /> End Sub<br /> Public Sub transferData(ByVal _lv As ListView)<br /> _lv.Clear()<br /> For Each d As DataColumn In dt.Columns<br /> Dim c As New ColumnHeader<br /> c.Text = d.ColumnName<br /> c.Width = _lv.Width / dt.Columns.Count<br /> c.TextAlign = HorizontalAlignment.Center<br /> _lv.Columns.Add(c)<br /> Next<br /> For Each dr As DataRow In dt.Rows<br /> Dim items(dt.Columns.Count) As String<br /> Dim ctr As Integer = 0<br /> For Each itemRow As Object In dr.ItemArray<br /> items(ctr) = itemRow.ToString<br /><br /> ctr += 1<br /> Next<br /><br /><br /> Dim xItem As New ListViewItem(items)<br /> _lv.Items.Add(xItem)<br /> Next<br /> End Sub</span><br />
<span style="color: #6fa8dc;"><br />End Module</span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<div style="text-align: center;">
USAGE</div>
<span style="color: #e06666;"> loadConnection("Provider=Microsoft.Ace.oledb.12.0; Data Source=myDatabase.accdb")<br /> execute("select * from BOOKS")<br /> setUpListView(ListView1)<br /> transferData(ListView1)</span><br />
<br />
<br />
<br />
<br />
<br />
Read <a href="http://kianaudez.blogspot.com/2014/03/simple-database-module.html">this </a>for more information<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-84968063439168191472014-03-03T11:20:00.001-08:002014-03-04T15:02:27.534-08:00Simple Database Module<div style="text-align: center;">
<b> The goal of the Module is to support the simple process for database connection</b></div>
<div style="text-align: center;">
<b>[C# + ACCESS]</b><br />
<b><a href="http://kianaudez.blogspot.com/2014/03/imports-system.html">[VB.NET + ACCESS]</a> </b></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
1.Create a new project [File >New> Project > Visual c# > name it]</div>
<div style="text-align: left;">
2. Add new class on project[ Right Click > Add > Class > name it dCon] <span style="color: #93c47d;">A new class will be created</span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: black;">3.Import or use the ff. Libraries. At the top of your class, add the following lines</span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;">using System;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Text;<br />using System.Data.OleDb;<br />using System.Data;<br />using System.Drawing;<br />using System.Linq;<br />using System.Text;<span style="background-color: #93c47d;"></span><br />using System.Windows.Forms; </span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">4. Change the property of the class, make it public and static</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"> Public- the method or class can be accessed outside the class</span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"> Static - Create one static instance[Only load once]</span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"> public static class dCon1<br /> {<br /> }</span></span></div>
<div style="text-align: left;">
5. Create datatypes, constructor or methods etc to be used. </div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"> public static OleDbConnection dbConnect;<br /> public static OleDbDataAdapter da; <br /> public static DataTable dt; </span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;">[we created a new oledbconnect, data adapter and datatable. All static and public] </span></div>
<div style="text-align: left;">
<span style="color: #93c47d;">[datatable is responsible for getting/setting the datas to be read or write by the adapter]</span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
6.Create the methods. First write the method to connect or open or establish a connection to the database[access]</div>
<div style="text-align: left;">
<span style="color: #93c47d;"> <span style="color: #6fa8dc;"> public static void loadConnection()<br /> {<br /> string conStr = "Provider=Microsoft.ACE.oledb.12.0;Data Source=Database/gameDb.accdb";<br /> dbConnect = new OleDbConnection(conStr);<br /> dbConnect.Open();<br /> }</span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"> </span> </span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"> <span style="color: #93c47d;">[We created a public static loadConnection method, this must be called first to load the connection]</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;">[Change the Data Source to the location of your database and its name, Provider is the driver that connects your database to your program.]</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;">[Create the connect] - dbConnect= new OleDbConnection(conStr);</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;">[Then open it]</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="background-color: white;"><span style="color: #93c47d;">7. Create a method that will accept a sql and execute it</span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"> <span style="color: #6fa8dc;">public static void execute(string sql)<br /> {<br /> dt = new DataTable(); //<span style="color: #93c47d;">create/recreate the datable as new. So we dont have to create a new datable instance</span><br /> if (dbConnect.State == System.Data.ConnectionState.Open)<br /> {<br /> da = new OleDbDataAdapter(sql, dbConnect);<br /> da.Fill(dt);<br /> }<br /> }</span></span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"><span style="color: #6fa8dc;">If the<span style="color: #93c47d;"> connection is open, recreate the dataadapter and send the sql.</span></span></span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;">Store the data to the datatable dt.</span></span></span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
8. Create a method that will accept a listview and fill it with the datas in the datatable dt</div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"> <span style="color: #6fa8dc;"> public static void transferData(ListView _lv)<br /> {<br /> _lv.Clear();<br /> ListView newLv = new ListView();<br /> newLv = _lv;<br /> foreach (DataColumn d in dt.Columns)<br /> {<br /> ColumnHeader c = new ColumnHeader();<br /> c.Text = d.ColumnName;<br /> c.Width = _lv.Width / dt.Columns.Count;<br /> c.TextAlign = HorizontalAlignment.Center;<br /> _lv.Columns.Add(c);<br /> }<br /> foreach (DataRow row in dt.Rows)<br /> {<br /> string[] items = new string[dt.Columns.Count];<br /> int ctr = 0;<br /> foreach (var i in row.ItemArray)<br /> {<br /> items[ctr] = i.ToString();<br /> ctr++;<br /> }<br /> ListViewItem item = new ListViewItem(items);<br /> _lv.Items.Add(item);<br /> }<br /><br /> }</span> </span> </span></span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: #93c47d;">[Any listview will do since it will automatically fetch the column names then adds the data to the rows of the listview]</span> </span> </span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">Now we're done..</span></span></span></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">You can now use it in your form methods by typing dCon.execute("") etc</span></span></span></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">Dont forget to loadtheconnection first before using the methods execute or transferData.</span></span></span></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">On your first form_load event type.</span></span></span></div>
<div style="text-align: center;">
<span style="color: #6fa8dc;">dCon.loadConnection();</span></div>
<div style="text-align: center;">
</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">Examples:</span></span></span></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">1. Select all the information in the products table and display it on the listview</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;"> >dCon.execute("select * from products")</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>transferData(listView1);</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">2. Check if a user with the username admin and password admin exists.</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.execute("select * from tblUsers where username='admin' and password='admin' ")</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>if(dCon.dt.Rows.Count != 0) MessageBox.Show("user exists!")</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">3.Get the registration date of the user admin from the USERS table and prompt it</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.execute("select * from tblUsers where username='admin'") ;</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">> DateTime dateOfBirth = DateTime.Parse(dCon.dt.Rows[0]["dateRegistration"].ToString());</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">4. Insert a new record to the tblUsers then display it on a listview</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.execute("Insert into tblUsers(username,password,dateRegistration) values('kevin','ilovechiro143ahahaha','DateTime.Now'");</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.transfer(listView1);</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">5. Update password of user kevin</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.execute("UPDATE tblUsers set password='ilovechiro' where username='kevin' ");</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">6.Delete user where username is kevin</span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;">>dCon.execute("DELETE FROM tblUsers where username='kevin'");</span></span></span></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: center;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;"><span style="color: #e06666;"><b>MORE UPDATES TO COME</b></span> </span></span></span></div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;"><br /></span></span></span></div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"><span style="color: black;"> </span> </span></span></div>
<div style="text-align: left;">
</div>
<div style="text-align: left;">
<span style="color: #93c47d;"><span style="color: #6fa8dc;"> </span> </span></div>
<div style="text-align: left;">
<br /></div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-69574964539819771012014-03-03T10:49:00.001-08:002014-03-03T20:43:24.072-08:00Lord of Strings<!--[if gte mso 9]><xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
</o:OfficeDocumentSettings>
</xml><![endif]--><br />
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>JA</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
<w:UseFELayout/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val="Cambria Math"/>
<m:brkBin m:val="before"/>
<m:brkBinSub m:val="--"/>
<m:smallFrac m:val="off"/>
<m:dispDef/>
<m:lMargin m:val="0"/>
<m:rMargin m:val="0"/>
<m:defJc m:val="centerGroup"/>
<m:wrapIndent m:val="1440"/>
<m:intLim m:val="subSup"/>
<m:naryLim m:val="undOvr"/>
</m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
DefSemiHidden="true" DefQFormat="false" DefPriority="99"
LatentStyleCount="267">
<w:LsdException Locked="false" Priority="0" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
<w:LsdException Locked="false" Priority="9" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 2"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 3"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
<w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
<w:LsdException Locked="false" Priority="39" Name="toc 1"/>
<w:LsdException Locked="false" Priority="39" Name="toc 2"/>
<w:LsdException Locked="false" Priority="39" Name="toc 3"/>
<w:LsdException Locked="false" Priority="39" Name="toc 4"/>
<w:LsdException Locked="false" Priority="39" Name="toc 5"/>
<w:LsdException Locked="false" Priority="39" Name="toc 6"/>
<w:LsdException Locked="false" Priority="39" Name="toc 7"/>
<w:LsdException Locked="false" Priority="39" Name="toc 8"/>
<w:LsdException Locked="false" Priority="39" Name="toc 9"/>
<w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
<w:LsdException Locked="false" Priority="10" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Title"/>
<w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
<w:LsdException Locked="false" Priority="11" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
<w:LsdException Locked="false" Priority="22" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
<w:LsdException Locked="false" Priority="20" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
<w:LsdException Locked="false" Priority="59" SemiHidden="false"
UnhideWhenUsed="false" Name="Table Grid"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
<w:LsdException Locked="false" Priority="1" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 1"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
<w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
<w:LsdException Locked="false" Priority="34" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
<w:LsdException Locked="false" Priority="29" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
<w:LsdException Locked="false" Priority="30" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 1"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 2"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 2"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 3"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 3"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 4"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 4"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 5"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 5"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
<w:LsdException Locked="false" Priority="60" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
<w:LsdException Locked="false" Priority="61" SemiHidden="false"
UnhideWhenUsed="false" Name="Light List Accent 6"/>
<w:LsdException Locked="false" Priority="62" SemiHidden="false"
UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
<w:LsdException Locked="false" Priority="63" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
<w:LsdException Locked="false" Priority="64" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
<w:LsdException Locked="false" Priority="65" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
<w:LsdException Locked="false" Priority="66" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
<w:LsdException Locked="false" Priority="67" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
<w:LsdException Locked="false" Priority="68" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
<w:LsdException Locked="false" Priority="69" SemiHidden="false"
UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
<w:LsdException Locked="false" Priority="70" SemiHidden="false"
UnhideWhenUsed="false" Name="Dark List Accent 6"/>
<w:LsdException Locked="false" Priority="71" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
<w:LsdException Locked="false" Priority="72" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
<w:LsdException Locked="false" Priority="73" SemiHidden="false"
UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
<w:LsdException Locked="false" Priority="19" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
<w:LsdException Locked="false" Priority="21" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
<w:LsdException Locked="false" Priority="31" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
<w:LsdException Locked="false" Priority="32" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
<w:LsdException Locked="false" Priority="33" SemiHidden="false"
UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
<w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
<w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin-top:0in;
mso-para-margin-right:0in;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0in;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
</style>
<![endif]-->
<br />
<div align="center" class="MsoNoSpacing" style="text-align: center;">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Program Generated Problems</span></b></div>
<div align="center" class="MsoNoSpacing" style="text-align: center;">
<span lang="EN-PH" style="color: #31849b; font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt; mso-themecolor: accent5; mso-themeshade: 191;">[<b style="mso-bidi-font-weight: normal;">Nalimits.tk</b>]</span></div>
<div align="center" class="MsoNoSpacing" style="text-align: center;">
<span lang="EN-PH" style="color: #31849b; font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt; mso-themecolor: accent5; mso-themeshade: 191;">[<b style="mso-bidi-font-weight: normal;">kianaudez.blogspot.com</b>]</span><br />
<br />
<h2>
<span lang="EN-PH" style="color: #31849b; font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt; mso-themecolor: accent5; mso-themeshade: 191;"><span style="color: #93c47d;"><span style="font-size: small;"><span style="font-family: "Courier New",Courier,monospace;">If you have problems or you want me to solve anything, please post a comment :D</span></span></span> </span></h2>
</div>
<div align="center" class="MsoNoSpacing" style="text-align: center;">
<br /></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Getting
the first three character of the product name</span></b></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Textbox1.Text
= the field that accepts the product name.</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Method
to use Substring or loop</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">>substring
method</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">C#</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">string
firstThreeLetter = TextBox1.Text.Substring(0,3);</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">[Good
to use when product names length >= 3 else error]</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String
firstThreeLetter =
TextBox1.Text.Substring(0,Math.Min(3,TextBox1.Text.Length());</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">[Good
to use whatever the length of TextBox1.Text is.. Math.Min(returns 3 if the
length >=3 else returns the length of the text(textbox1.text)]</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">LOOP
METHOD</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String
firstThreeLetter= “”;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Foreach
(char c in TextBox1.Text){</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">If(firstThreeLetter.Length
<= 2){</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>firstThreeLetter.Length += c;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">[Good to use when there are conditions for example
: Checking if the character is symbol or not ]</span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Getting
the First three alpha Numeric character of the product name</span></b></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">>Method
To use: Loop[detects if char is letter or digit]</span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">LOOP
METHOD</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String
firstThreeLetter= “”;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Foreach
(char c in TextBox1.Text){</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">If(firstThreeLetter.Length
<= 2){</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>If(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">char</span><span style="font-family: Consolas; font-size: 9.5pt;">.IsLetterOrDigit(TextBox1.Text))</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<br />
<span style="mso-tab-count: 2;"> </span></span><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">firstThreeLetter.Length
+= c;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Getting
the First three Symbols of the product name</span></b></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">>Method
To use: Loop[detects if char is letter or digit]</span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">LOOP
METHOD</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String
firstThreeLetter= “”;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Foreach
(char c in TextBox1.Text){</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">If(firstThreeLetter.Length
<= 2){</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>If(</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">char</span><span style="font-family: Consolas; font-size: 9.5pt;">.IsSymbol(TextBox1.Text))</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<br />
<span style="mso-tab-count: 2;"> </span></span><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">firstThreeLetter.Length
+= c;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Checking
if the first Letter is Symbol (input<span style="mso-spacerun: yes;">
</span>assumed > 0)</span></b></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>If(char.IsSymBol(TextBox1.Text[0])){
MessageBox.Show(“TRUE”); }</span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Checking
if the first Letter is NOT Symbol (input<span style="mso-spacerun: yes;">
</span>assumed > 0) [only accept alpha numeric]</span></b></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>If(!char.IsSymBol(TextBox1.Text[0])){
MessageBox.Show(“TRUE”); }</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.5in; text-indent: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Or</span></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span>If(!char.IsLetter(TextBox1.Text[0])){
MessageBox.Show(“TRUE”); }</span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Replace
certain character with symbol[example: Replace vowel w/ *]</span></b></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span></b><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">[brute
force method] disadvantage: when there are many characters to be replaced.</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span><span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text = TextBox1.Text.Replace(<span style="color: #a31515;">'a'</span>, <span style="color: #a31515;">'*'</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text
= TextBox1.Text.Replace(<span style="color: #a31515;">'e'</span>, <span style="color: #a31515;">'*'</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text
= TextBox1.Text.Replace(<span style="color: #a31515;">'i'</span>, <span style="color: #a31515;">'*'</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text
= TextBox1.Text.Replace(<span style="color: #a31515;">'o'</span>, <span style="color: #a31515;">'*'</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text
= TextBox1.Text.Replace(<span style="color: #a31515;">'u'</span>, <span style="color: #a31515;">'*'</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">[loop
method]</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span>TextBox1.Text =<span style="color: #a31515;">"All
The vowels here will be replaced. "</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>TextBox1.Text = TextBox1.Text.ToLower();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">string</span> output = <span style="color: #a31515;">""</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 0; x
< TextBox1.Text.Length; x++ )</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">if</span> (TextBox1.Text[x] == <span style="color: #a31515;">'a' </span><span style="mso-spacerun: yes;"> </span>|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] == <span style="color: #a31515;">'e'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] == <span style="color: #a31515;">'i'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
== <span style="color: #a31515;">'o'</span> ||</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
== <span style="color: #a31515;">'u'</span>)</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>output += <span style="color: #a31515;">'*'</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">else</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>output += TextBox1.Text[x];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Getting The First
Three consonant letters </span></b></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span style="font-size: 10.5pt; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String firstThreeLetter= “”;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Foreach
(char c in TextBox1.Text){</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">If(firstThreeLetter.Length
<= 2)</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">if</span> (TextBox1.Text[x] != <span style="color: #a31515;">'a' </span><span style="mso-spacerun: yes;"> </span>|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] != <span style="color: #a31515;">'e'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] != <span style="color: #a31515;">'i'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
!= <span style="color: #a31515;">'o'</span> ||</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
!= <span style="color: #a31515;">'u'</span>)</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in; text-indent: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">firstThreeLetter.Length += c;</span><span lang="EN-PH" style="font-family: Consolas; font-size: 9.5pt;"> </span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNoSpacing" style="margin-left: .5in; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Getting The First
Three Vowel letters </span></b></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span style="font-size: 10.5pt; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">String firstThreeLetter= “”;</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Foreach
(char c in TextBox1.Text){</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">If(firstThreeLetter.Length
<= 2)</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span><span style="color: blue;">if</span> (TextBox1.Text[x] == <span style="color: #a31515;">'a' </span><span style="mso-spacerun: yes;"> </span>|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] == <span style="color: #a31515;">'e'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x] == <span style="color: #a31515;">'i'</span>
|| </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
== <span style="color: #a31515;">'o'</span> ||</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">TextBox1.Text[x]
== <span style="color: #a31515;">'u'</span>)</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>{</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in; text-indent: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">firstThreeLetter.Length += c;</span><span lang="EN-PH" style="font-family: Consolas; font-size: 9.5pt;"> </span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNoSpacing" style="margin-left: .5in; text-indent: .5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>}</span></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<br /></div>
<div class="MsoNoSpacing" style="margin-left: 1.0in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">}</span></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Generating
a 5-digit number [4 random padded by zero]</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Random</span><span style="font-family: Consolas; font-size: 9.5pt;"> rand = <span style="color: blue;">new</span> <span style="color: #2b91af;">Random</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">string</span> randCode = <span style="color: #a31515;">"0"</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>randCode += rand.Next(0, 9);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>randCode += rand.Next(0, 9);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>randCode += rand.Next(0, 9);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">
</span>randCode += rand.Next(0, 9);</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.WriteLine(randCode);</span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Removing the
whitespace of string</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">string</span>
TextBox1Text =<span style="color: #a31515;">"All The spaces here will be
removed. "</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">string</span>
output = <span style="color: #a31515;">""</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> x = 0; x < TextBox1Text.Length; x++ )</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">if</span>(!<span style="color: blue;">char</span>.IsWhiteSpace(TextBox1Text[x]))</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>output += TextBox1Text[x];</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>} </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; tab-stops: center 3.5in; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.Write(output);<span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></b></div>
<div class="MsoNoSpacing">
<b style="mso-bidi-font-weight: normal;"><span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;">Getting
the remainder of the product quantity divided by 10</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;"> </span><span style="color: blue;">int</span> qty = 156;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">int</span> remainder = qty % 10;<span style="color: #2b91af;"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Getting the
percentage of a value (example : 22% of 100)</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span><span style="mso-spacerun: yes;">
</span></span></b><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">double</span><span style="font-family: Consolas; font-size: 9.5pt;"> output = 1000 * 0.22;</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Getting The Current
Date</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></b><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">string</span><span style="font-family: Consolas; font-size: 9.5pt;"> output = <span style="color: #2b91af;">DateTime</span>.Now.ToShortDateString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;">Getting The Current
Day of Week (Monday,Tuesday,Wednesday etc..)</span></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></b><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">string</span><span style="font-family: Consolas; font-size: 9.5pt;"> output = <span style="color: #2b91af;">DateTime</span>.Now.DayOfWeek.ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: center;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="font-size: x-large;"><span style="color: #3d85c6;">More UPDATES soon!</span></span> </span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<b style="mso-bidi-font-weight: normal;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-tab-count: 1;"> </span></span></b></div>
<div class="MsoNoSpacing" style="margin-left: .5in;">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNoSpacing">
<span lang="EN-PH" style="font-size: 10.5pt; mso-ansi-language: EN-PH; mso-bidi-font-size: 11.0pt;"><span style="mso-tab-count: 1;"> </span></span></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="MsoNoSpacing">
<br /></div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-2134838511344999632014-03-03T10:30:00.001-08:002014-03-03T10:30:23.247-08:00How to open downloaded source codes when visual studio displays error on solution load<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQLoc-GvpB-_vUBBW_i9E60UEmVChL4DGBwZHe8G54gbzdpnbjUAlbx5Khw2qLzqJKqKc8ooFoLuHwyfPgC8tXAdfy5WcTnjG_ERIxgtQe1YH4LLSI2PhgOZV7dNnaZCdGkEO61evh/s1600/Creating+New+Solution+and+adding+existing+project+-+1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQLoc-GvpB-_vUBBW_i9E60UEmVChL4DGBwZHe8G54gbzdpnbjUAlbx5Khw2qLzqJKqKc8ooFoLuHwyfPgC8tXAdfy5WcTnjG_ERIxgtQe1YH4LLSI2PhgOZV7dNnaZCdGkEO61evh/s1600/Creating+New+Solution+and+adding+existing+project+-+1.png" height="197" width="320" /></a></div>
<div style="text-align: center;">
[Step 1: create a new project]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6K8lsARHW9pD1sbQTZYGii7yhO4xKatbmeQt-8KugPNmu8cTyIH_VWca223_5CcnTnzGXqgqYpOAB7F1L8nmRSb-MbGNblVkkV4NWb_B64gNAZ6Fo2cv9v8fCPibpxp0Iv3UpjwrZ/s1600/Creating+New+Solution+and+adding+existing+project+-+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6K8lsARHW9pD1sbQTZYGii7yhO4xKatbmeQt-8KugPNmu8cTyIH_VWca223_5CcnTnzGXqgqYpOAB7F1L8nmRSb-MbGNblVkkV4NWb_B64gNAZ6Fo2cv9v8fCPibpxp0Iv3UpjwrZ/s1600/Creating+New+Solution+and+adding+existing+project+-+2.png" height="219" width="320" /></a></div>
<div style="text-align: center;">
[Step 2: click the template for this example XNA Game Studio 4.0]</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2QJXoDOgue1v3XRFzibI3_UfUbzvyWE_IC8erxsP90wPmXfyFAcpKYpUGWLRrtpYuypQ-mAxQNtAePJh-vYwlDqCrn3SPX4FKMRn4AkYhs7pxvZs8OQNZkQHDhcTSJti08cJsIHfP/s1600/Creating+New+Solution+and+adding+existing+project+-+3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2QJXoDOgue1v3XRFzibI3_UfUbzvyWE_IC8erxsP90wPmXfyFAcpKYpUGWLRrtpYuypQ-mAxQNtAePJh-vYwlDqCrn3SPX4FKMRn4AkYhs7pxvZs8OQNZkQHDhcTSJti08cJsIHfP/s1600/Creating+New+Solution+and+adding+existing+project+-+3.png" height="320" width="257" /></a></div>
<div style="text-align: center;">
[Step 3: Remove New projects]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnCrl7e0DuUNsZFEv7hAH-csDsTI5VBJ3Yo4eUWKygxr-U-R6xWSMi14hR86psWOvSgwzbfU3AqNO3ewK02zvyOBAKmYam3JquSSibDQfDsRmfaqYaYgCbZ_wc-gw8jwRiD0tCyJrP/s1600/Creating+New+Solution+and+adding+existing+project+-+4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnCrl7e0DuUNsZFEv7hAH-csDsTI5VBJ3Yo4eUWKygxr-U-R6xWSMi14hR86psWOvSgwzbfU3AqNO3ewK02zvyOBAKmYam3JquSSibDQfDsRmfaqYaYgCbZ_wc-gw8jwRiD0tCyJrP/s1600/Creating+New+Solution+and+adding+existing+project+-+4.png" height="251" width="320" /></a></div>
<div style="text-align: center;">
[Step 3: Remove New projects]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU8r0e6EhZ6wxlE9SOpw7CrId51Qu_cSfUrs0vFZI_tAZVUduSDbmO_c0hSDC1Oz1dvZ2JEqlUZnufnt1ZVPgdwwF5_1qStGJ8CpDyBIik-MVg3-IUKh6__iCqerMFgI8aecjTP8W5/s1600/Creating+New+Solution+and+adding+existing+project+-+5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU8r0e6EhZ6wxlE9SOpw7CrId51Qu_cSfUrs0vFZI_tAZVUduSDbmO_c0hSDC1Oz1dvZ2JEqlUZnufnt1ZVPgdwwF5_1qStGJ8CpDyBIik-MVg3-IUKh6__iCqerMFgI8aecjTP8W5/s1600/Creating+New+Solution+and+adding+existing+project+-+5.png" height="115" width="320" /></a></div>
<div style="text-align: center;">
[Step 4: Add the downloaded source code (project files)]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJrDizxXLqUynnZPcJxnEwdAdhDowkDhY8-GXTO-YcwxXDsVQUcu4Fwzkko9qJTmn_eS429RoraXZWpDM1mhUeTZpQot-61yl22AVwElp6h1BO_9Kb1tvDzbvOKshNuScCpiede2uZ/s1600/Creating+New+Solution+and+adding+existing+project+-+6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJrDizxXLqUynnZPcJxnEwdAdhDowkDhY8-GXTO-YcwxXDsVQUcu4Fwzkko9qJTmn_eS429RoraXZWpDM1mhUeTZpQot-61yl22AVwElp6h1BO_9Kb1tvDzbvOKshNuScCpiede2uZ/s1600/Creating+New+Solution+and+adding+existing+project+-+6.png" height="205" width="320" /></a></div>
<div style="text-align: center;">
[Step 5: Browse for the Project file]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUYtGEVdkz0RDdInYxLK9PmDENO9-wCZlk-cysiEYRqiH3JAzeKUvva9Z1qV8V3FHVQzybv7v3RUvT2LpLQ3dn0l37JbItoKbVc-LeKHm0digkTBXGSwzEvGm-NY8hH4wcuQ-bLnK2/s1600/Creating+New+Solution+and+adding+existing+project+-+7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUYtGEVdkz0RDdInYxLK9PmDENO9-wCZlk-cysiEYRqiH3JAzeKUvva9Z1qV8V3FHVQzybv7v3RUvT2LpLQ3dn0l37JbItoKbVc-LeKHm0digkTBXGSwzEvGm-NY8hH4wcuQ-bLnK2/s1600/Creating+New+Solution+and+adding+existing+project+-+7.png" height="176" width="320" /></a></div>
<br />
<div style="text-align: center;">
[Step 5.1: Browse for the Resource Project file]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1E1uMrPFVHruII53CHZPaXX8eBa2XGvTTVhcJ5cVrxv9SJrWxeTtHWiqtAPbJ-cHgG5MlwlBZujHxoQ77MAItlTy7ND7I0k6SfZtk5h7kYuVPR4V9pw7gFyzUct2As6RjH8XsNMtr/s1600/Creating+New+Solution+and+adding+existing+project+-+8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1E1uMrPFVHruII53CHZPaXX8eBa2XGvTTVhcJ5cVrxv9SJrWxeTtHWiqtAPbJ-cHgG5MlwlBZujHxoQ77MAItlTy7ND7I0k6SfZtk5h7kYuVPR4V9pw7gFyzUct2As6RjH8XsNMtr/s1600/Creating+New+Solution+and+adding+existing+project+-+8.png" height="140" width="320" /></a></div>
<div style="text-align: center;">
[Compile and RUN!!!!]</div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com2tag:blogger.com,1999:blog-2223650567918689977.post-24983433499614955292014-02-20T06:13:00.003-08:002014-03-03T10:31:33.016-08:00Game development with C# and XNA FRAMEWORK<div style="text-align: center;">
<span style="color: #3d85c6; font-size: large;">Flappy birds Ripoff</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBjGzTTiXWmkjwE0t31GFRWuDI-8L1mxsseFV2BKUUuw14hA1ldGhf0ymetQ-m_9iZTMNZbE4Ad-CIWssPaHbblUPg4lUT4IJ9qZG_H3uZpHkg25U3Q2KxBlc9-Viyc5cYseHCyzAp/s1600/XNAFRAMEWORK+FLAPPYBIRDS+RIPOFF.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBjGzTTiXWmkjwE0t31GFRWuDI-8L1mxsseFV2BKUUuw14hA1ldGhf0ymetQ-m_9iZTMNZbE4Ad-CIWssPaHbblUPg4lUT4IJ9qZG_H3uZpHkg25U3Q2KxBlc9-Viyc5cYseHCyzAp/s1600/XNAFRAMEWORK+FLAPPYBIRDS+RIPOFF.png" height="320" width="303" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[Screenshot]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/ORuq9S5os1g?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
[Video]</div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #6aa84f;">[Source code of unfinished game activity @ Game development with c# and XNA framework..]</span></div>
<br />
<span style="color: #e06666;">Requirements:</span><br />
<a href="http://www.microsoft.com/en-ph/download/details.aspx?id=23714">XNA Game studio FRAMEWORK</a><br />
Visual Studio<br />
<a href="http://www.microsoft.com/en-ph/download/details.aspx?id=20914">Download XNA FRAMEWORK REDIST</a> [To run exe file]<br />
<br />
<a href="https://drive.google.com/file/d/0B6W-ys2F8Fa-VW1NM216ZkpPbTA/edit?usp=sharing">Download Executable game here (requires XNA FRAMEWORK REFRESH REDIST)</a><br />
<a href="https://drive.google.com/file/d/0B6W-ys2F8Fa-U19iSGpWUDllazA/edit?usp=sharing">Download Source code here</a><br />
<br />
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<span style="color: #cc0000;">[ Download Instructions]</span></div>
<div style="text-align: center;">
<span style="color: #cc0000;">Press File > Download or Ctrl+s to save file</span><br />
<a href="http://kianaudez.blogspot.com/2014/03/how-to-open-downloaded-source-codes.html"><span style="color: #cc0000; font-size: large;">[Error ? opening the solution Click HERE] </span></a></div>
<br />
<br />
<br />
<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-39837607161061583422014-01-30T05:50:00.003-08:002014-03-16T19:54:09.149-07:00Xnalimits - Portfolio<h2>
<b>2D Games</b></h2>
<div style="text-align: center;">
<b>Flappy Birds Ripoff</b></div>
<div style="text-align: center;">
<b>For tutorial and seminar purposes only</b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmkU4diKoQ-o2IBexdJXWhjfjIP9GcOKVEBhm6qb3MiRFCFrJg2xHQ8OWcE-cpTLdVS-aS3Es8AbQtRq6Qqm_EdUQW9er30JdxcfW-t3C8l2jAfLtt8yfCM8uCUA-Odu-FhpId9b3Y/s1600/XNAFRAMEWORK+FLAPPYBIRDS+RIPOFF.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmkU4diKoQ-o2IBexdJXWhjfjIP9GcOKVEBhm6qb3MiRFCFrJg2xHQ8OWcE-cpTLdVS-aS3Es8AbQtRq6Qqm_EdUQW9er30JdxcfW-t3C8l2jAfLtt8yfCM8uCUA-Odu-FhpId9b3Y/s1600/XNAFRAMEWORK+FLAPPYBIRDS+RIPOFF.png" height="320" width="303" /></a></div>
<div style="text-align: center;">
<b><br /></b></div>
<br />
<br />
<div style="text-align: center;">
<b>Monkey and Balloons</b></div>
<div style="text-align: center;">
<b>a 2d platform game developed in c# and xna</b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTjYTzviuJetLawbgilSw_6_97IuU1a6wYNBLB3apXZ0f_2p5I11DLDj9qfnRofbtJaOAb4cCsF-wBa33DY9SlDraiy7m0RzVyG4s3CqIEcGnQZpGgHbwieujCZdWYziLYaZGTbT6I/s1600/xnalimits+-+xna+monkey+platform+game+title+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTjYTzviuJetLawbgilSw_6_97IuU1a6wYNBLB3apXZ0f_2p5I11DLDj9qfnRofbtJaOAb4cCsF-wBa33DY9SlDraiy7m0RzVyG4s3CqIEcGnQZpGgHbwieujCZdWYziLYaZGTbT6I/s1600/xnalimits+-+xna+monkey+platform+game+title+screen.png" height="248" width="320" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmTo-lz80tX6D_tE34PClDmtpYQDWNTewy-7ZSWPd82_A343fYG26x0effFYaO1XG4IZtNBkIHtUj56c5Z8kbSdETAVdMbDcZxBLT3kwUFwxLpTq2TRpYYPNxhFo3dMRdwEIcB4qUM/s1600/xnalimits+-+xna+monkey+platform+game.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgmTo-lz80tX6D_tE34PClDmtpYQDWNTewy-7ZSWPd82_A343fYG26x0effFYaO1XG4IZtNBkIHtUj56c5Z8kbSdETAVdMbDcZxBLT3kwUFwxLpTq2TRpYYPNxhFo3dMRdwEIcB4qUM/s1600/xnalimits+-+xna+monkey+platform+game.png" height="246" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaqy09ChhXt3XlWsD2mQSQtNk7j5Fhx7DjaE4WbM6Nh3QUt4CRBwS8kDVSUD1AtftaZA-liBLnesuQj60SLR4M1EPBozpqsDZ_C1hW8LCTvIoJVV9CUDxT6fEGwqIbd_7ujdSL7slV/s1600/xnalimits+-+xna+monkey+platform+game+Game+over.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaqy09ChhXt3XlWsD2mQSQtNk7j5Fhx7DjaE4WbM6Nh3QUt4CRBwS8kDVSUD1AtftaZA-liBLnesuQj60SLR4M1EPBozpqsDZ_C1hW8LCTvIoJVV9CUDxT6fEGwqIbd_7ujdSL7slV/s1600/xnalimits+-+xna+monkey+platform+game+Game+over.png" height="249" width="320" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b>ToD </b></div>
<div class="separator" style="clear: both; text-align: center;">
<b>a 2d Tank Shooting Game</b></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq2Daqk2pDQdGahL9K50tSKzK9sQ1gx34rWR_7NBmvfBi4VGRZ5cDwYn7mSpaXSMpRCI4DLBzuDXc1IRjONQx_0TUDFQiwXfFBLOwKxln8MfcCll_CYe48rHu6Ox_MYIsOhyakPvEt/s1600/Tod+-+XNA+2D+tank+game.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhq2Daqk2pDQdGahL9K50tSKzK9sQ1gx34rWR_7NBmvfBi4VGRZ5cDwYn7mSpaXSMpRCI4DLBzuDXc1IRjONQx_0TUDFQiwXfFBLOwKxln8MfcCll_CYe48rHu6Ox_MYIsOhyakPvEt/s1600/Tod+-+XNA+2D+tank+game.png" height="236" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b>Legend Of Heroes </b></div>
<div class="separator" style="clear: both; text-align: center;">
<b>a 2D rpg prototype made with c# and XNA</b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3cdIx0e5qq9HTYLpoppdY7cPIq1S-qSGst3svfG46HEv0BM2a90bEe1BqvO_UCdeffFwigFs9aIgssZa8VvowpC2F7Tt07hE2uyBP9coLvy-dNxyfCC505D4Gb3to0VYyQOcsMNid/s1600/RPG+legend+of+heroes+game+screen-+XNA+c%23.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3cdIx0e5qq9HTYLpoppdY7cPIq1S-qSGst3svfG46HEv0BM2a90bEe1BqvO_UCdeffFwigFs9aIgssZa8VvowpC2F7Tt07hE2uyBP9coLvy-dNxyfCC505D4Gb3to0VYyQOcsMNid/s1600/RPG+legend+of+heroes+game+screen-+XNA+c%23.png" height="237" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVPfKolNHFt2gEJRO8nXosVezR9TqhFK03ybXSVPvgdB2TEPyp4fmm5h_8kJIEagx3TfUFfO9uitXYwOpygTdxcZ5mr-my6vL1_dzz2mn56ldZAZmdTyLlOBEgNefCyxM2NOnIdCyL/s1600/RPG+legend+of+heroes+title+screen+-+XNA+c%23.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVPfKolNHFt2gEJRO8nXosVezR9TqhFK03ybXSVPvgdB2TEPyp4fmm5h_8kJIEagx3TfUFfO9uitXYwOpygTdxcZ5mr-my6vL1_dzz2mn56ldZAZmdTyLlOBEgNefCyxM2NOnIdCyL/s1600/RPG+legend+of+heroes+title+screen+-+XNA+c%23.png" height="237" width="320" /></a></div>
<h2 class="separator" style="clear: both; text-align: center;">
<b> </b></h2>
<div style="text-align: left;">
<h2>
<b>3D Games</b></h2>
</div>
<div style="text-align: center;">
<b>Asylum</b></div>
<div style="text-align: center;">
A game made within 48 hours for global game jam competition.</div>
<div style="text-align: center;">
Coded in c# and Xna, models from 3ds max and maya.</div>
<div style="text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgFcn7ZN-DSKV303KMekfbytvZVfuvdiwYB_03cUEL3FRf6WOmRSNwTjRPwhGOD2ClkDZeH5OMldAuUt-B3pPMPfhb4wr2jTSSCEFkIiHRQ-rHyxcc48ZLdeRJOCHBgLyp8qVxs_ST/s1600/Asylum+-+3D+suspense+horror+game+title+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgFcn7ZN-DSKV303KMekfbytvZVfuvdiwYB_03cUEL3FRf6WOmRSNwTjRPwhGOD2ClkDZeH5OMldAuUt-B3pPMPfhb4wr2jTSSCEFkIiHRQ-rHyxcc48ZLdeRJOCHBgLyp8qVxs_ST/s1600/Asylum+-+3D+suspense+horror+game+title+screen.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4Bi4sxEBjqZ8ZdErukp0VOJN_mLO80ZSazdtYjXtFKIZA_QosMOF-Tj0tFtXJSNy_LRiMl_0K1nwLVfo0EP1zSbKwikp3NVUscpV62yRwY6GJpU2VotkuvZoQstG3McJA_sVj3dCE/s1600/asylum+-+3D+suspense+horror+game.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4Bi4sxEBjqZ8ZdErukp0VOJN_mLO80ZSazdtYjXtFKIZA_QosMOF-Tj0tFtXJSNy_LRiMl_0K1nwLVfo0EP1zSbKwikp3NVUscpV62yRwY6GJpU2VotkuvZoQstG3McJA_sVj3dCE/s1600/asylum+-+3D+suspense+horror+game.png" height="179" width="320" /></a></div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: center;">
<b>Legend Of Heroes - 3D Final game</b></div>
<div style="text-align: center;">
a 3D Role-Playing game coded in c# and xna for Thesis software<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoyyMbrnEpX_FQG2clCmRyaGH6GzwBmRfdTRwBG49zDeaJOyxAWAQZ_geuu9pHzdVKgtAb7E21LZ9ZMeAzrhZXGdEecKEoNDgiTb5Przp9l29Xzv8QOsES9520xyM2QtcUJRmSGGVk/s1600/XNA+C%23+RPG+-+Legend+of+Heroes+title+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoyyMbrnEpX_FQG2clCmRyaGH6GzwBmRfdTRwBG49zDeaJOyxAWAQZ_geuu9pHzdVKgtAb7E21LZ9ZMeAzrhZXGdEecKEoNDgiTb5Przp9l29Xzv8QOsES9520xyM2QtcUJRmSGGVk/s1600/XNA+C%23+RPG+-+Legend+of+Heroes+title+screen.png" height="223" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU-ckkpnNF-0lqkmiMBoWYrbBoObLKlloiw3_FRCJXOAORqlsZ1XlvUZLcss-121qQ7BYm6Vc9gXSnuN0N0lW5Hom_m4TOEYLPzqR2yzuW_3pa58fz8N1NNQALXXOfsIHt7bAEU1eu/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+registration+Screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjU-ckkpnNF-0lqkmiMBoWYrbBoObLKlloiw3_FRCJXOAORqlsZ1XlvUZLcss-121qQ7BYm6Vc9gXSnuN0N0lW5Hom_m4TOEYLPzqR2yzuW_3pa58fz8N1NNQALXXOfsIHt7bAEU1eu/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+registration+Screen.png" height="226" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivYqTvl6rXcRv1fQDoyMqMUn75ME6z8wUC9Aecm17bpCsLVnerWeuZYA1THuOxFbmJtRWN8zy5anWrA2uHmxLoKQaUCOH-mk22ip7V2QemQ6djea1P9MTbr5s3RxfxxAgpPkmDmdTt/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+character+creation+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivYqTvl6rXcRv1fQDoyMqMUn75ME6z8wUC9Aecm17bpCsLVnerWeuZYA1THuOxFbmJtRWN8zy5anWrA2uHmxLoKQaUCOH-mk22ip7V2QemQ6djea1P9MTbr5s3RxfxxAgpPkmDmdTt/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+character+creation+screen.png" height="225" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg45zO-XhlLjLDTR_rZ9BWW-fpgQlDb9Oocd_wCX4GCofee2rGpLpb55SIgR_vBChgwoUtrpAe_2cy46hmJ21V54QQoi9oaOof-PmlP7wS5-RhMcopCyfzgtTn2FHhzCwO3tNDwmNTB/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+character+Selection+Screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg45zO-XhlLjLDTR_rZ9BWW-fpgQlDb9Oocd_wCX4GCofee2rGpLpb55SIgR_vBChgwoUtrpAe_2cy46hmJ21V54QQoi9oaOof-PmlP7wS5-RhMcopCyfzgtTn2FHhzCwO3tNDwmNTB/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+character+Selection+Screen.png" height="225" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJZrnwWLwDLg0r7aCgQbuGdYJiyFZrmlzweUpL_28ZGcBsHdRFsErs4_0sk_rjEnmKYjmas4S6e2jIEREIokfunjjoB5NOG40Hf8pADMtCr-Ovw3HrhueEhw8KJiF_yBqRxtq2VAdI/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+loading+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJZrnwWLwDLg0r7aCgQbuGdYJiyFZrmlzweUpL_28ZGcBsHdRFsErs4_0sk_rjEnmKYjmas4S6e2jIEREIokfunjjoB5NOG40Hf8pADMtCr-Ovw3HrhueEhw8KJiF_yBqRxtq2VAdI/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+loading+screen.png" height="224" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSUsza0I6snCCz8CzC2mTxM_Cu0pTeSP6dCziyeEuKgMru-FtnUxOi6sREeo7KpqqWk-wF0ZjP0M0eMew8EED5saYoscJ0-r2_h9cnheINzbkhFc6ZHfYcP27L3TPlQWx_J84rjw1c/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+gameplay+%252C+world.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSUsza0I6snCCz8CzC2mTxM_Cu0pTeSP6dCziyeEuKgMru-FtnUxOi6sREeo7KpqqWk-wF0ZjP0M0eMew8EED5saYoscJ0-r2_h9cnheINzbkhFc6ZHfYcP27L3TPlQWx_J84rjw1c/s1600/XNA+C%2523+RPG+-+Legend+of+Heroes+gameplay+%252C+world.png" height="225" width="320" /></a></div>
<br /></div>
<div style="text-align: center;">
<b>Terrain Tanks </b><br />
<b>a 3rd person shooting game using C# and XNA</b><br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_idd4WgngTF_9LwiH548hEvAXKWHS5yAGpPXT0RxCwmh_vuhjM4bPp8aCpi3TAsSQg9Z2-b2GVs6u5Of9WkCdq2XSxZRVa66El01jMPpWEBeU6JBe83hUJj8bI77XF1HlPu27JLGL/s1600/XNA+c%23+3d+3rd+person+shooter+-++terrain+Tanks+title+Screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_idd4WgngTF_9LwiH548hEvAXKWHS5yAGpPXT0RxCwmh_vuhjM4bPp8aCpi3TAsSQg9Z2-b2GVs6u5Of9WkCdq2XSxZRVa66El01jMPpWEBeU6JBe83hUJj8bI77XF1HlPu27JLGL/s1600/XNA+c%23+3d+3rd+person+shooter+-++terrain+Tanks+title+Screen.png" height="225" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJforAiiQU_q04gBm2SF3OYEr4A0H5LE4eQ0d1Xdu3T6-RrX4vU1IZLYwEEvazZGk2p4pngddy3DST-7rkXKPW2suZIeiOMWY5Qkxm9VVCEIvajXXnhVyt3M_IGDepqkBtNg47Sra3/s1600/XNA+c%23+3d+3rd+person+shooter+-++terrain+Tanks+GameScreen+world.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJforAiiQU_q04gBm2SF3OYEr4A0H5LE4eQ0d1Xdu3T6-RrX4vU1IZLYwEEvazZGk2p4pngddy3DST-7rkXKPW2suZIeiOMWY5Qkxm9VVCEIvajXXnhVyt3M_IGDepqkBtNg47Sra3/s1600/XNA+c%23+3d+3rd+person+shooter+-++terrain+Tanks+GameScreen+world.png" height="235" width="320" /> </a></div>
<div class="separator" style="clear: both; text-align: center;">
The English in Asia </div>
<div class="separator" style="clear: both; text-align: center;">
<b>a 3rd person naval shooting game using c#, Xna and DirectX</b></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGQLV5_NYyLp2dyebjeEHqSlqfY1wYfXaumqKHotr2h3hmwSiNLSXtByBhXA1Dx2MAPMlGh_mLMCa4eHtAm9916Q0pPTzIrxJ32pr8Mfa1a5fd19641bhytDbimIQQT2jy29UEI7bC/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+title+screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiGQLV5_NYyLp2dyebjeEHqSlqfY1wYfXaumqKHotr2h3hmwSiNLSXtByBhXA1Dx2MAPMlGh_mLMCa4eHtAm9916Q0pPTzIrxJ32pr8Mfa1a5fd19641bhytDbimIQQT2jy29UEI7bC/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+title+screen.png" height="224" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj79Yvct4R5lUC4IvfPr4PIwZgammDagHfBebDAQrT-g56IKRBOUphPAXYbSUxgt23bS1UAc6weOkUhag8YEJtk9TVQGWdfeyOEzMRF0fLGlyoUS2uTSoVrb326yW9p89d_EBzHrV0b/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+world.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj79Yvct4R5lUC4IvfPr4PIwZgammDagHfBebDAQrT-g56IKRBOUphPAXYbSUxgt23bS1UAc6weOkUhag8YEJtk9TVQGWdfeyOEzMRF0fLGlyoUS2uTSoVrb326yW9p89d_EBzHrV0b/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+world.png" height="224" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMc0CQN3eiBh_M86sAGECxXwFYdnBSzGt2B4DkP6mbmOUpf4ZlpOzxS3s9APFNGQ0cf3oLQrSPwIdoubkXeY5-Xg_JiuPkIkbeJ_zdmskE3N0lUYg73te9fEoBVHFTnCQTmSxaHqfW/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+quest.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMc0CQN3eiBh_M86sAGECxXwFYdnBSzGt2B4DkP6mbmOUpf4ZlpOzxS3s9APFNGQ0cf3oLQrSPwIdoubkXeY5-Xg_JiuPkIkbeJ_zdmskE3N0lUYg73te9fEoBVHFTnCQTmSxaHqfW/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+quest.png" height="224" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKHbns_XzQw-kYXA0iH8boWu2ifU5UazzdAqjMe98Xm5UANWV5AtzN19BMKO-CC-EASngtfa1xByIdn-O4HWhLYf90sq2_BgHqW-_3JVHox_0B3MbJlqjIRbbUUFnZxqyTu8O5AbtZ/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+battle+system.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKHbns_XzQw-kYXA0iH8boWu2ifU5UazzdAqjMe98Xm5UANWV5AtzN19BMKO-CC-EASngtfa1xByIdn-O4HWhLYf90sq2_BgHqW-_3JVHox_0B3MbJlqjIRbbUUFnZxqyTu8O5AbtZ/s1600/Xna+c%23+Direct-X+water+render+-+The+english+in+asia+battle+system.png" height="226" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b>And lastly, my first 3D game. </b></div>
<div class="separator" style="clear: both; text-align: center;">
<b>a 3rd person shooter using airplanes</b> </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6HkFG-vcjwOXW4_TEGHEZOAiPE57Ysuf7KdU0wqR2QOtkz6hY257KcoLdj9_xtDBc5tQCrLoiL7FuTuLx1f7Ewakjdf8mfoiHEbNM3nw5fDPxMIgrCTDAF_UyPWXRkzBZp4NqP2uH/s1600/XNA+c%23+3d+3rd+person+shooter+-++Plane+test+game+Screen.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6HkFG-vcjwOXW4_TEGHEZOAiPE57Ysuf7KdU0wqR2QOtkz6hY257KcoLdj9_xtDBc5tQCrLoiL7FuTuLx1f7Ewakjdf8mfoiHEbNM3nw5fDPxMIgrCTDAF_UyPWXRkzBZp4NqP2uH/s1600/XNA+c%23+3d+3rd+person+shooter+-++Plane+test+game+Screen.png" height="237" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
[Credits]</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.facebook.com/profile.php?id=1674473409&fref=ts">Patrick James Lim </a>for the Interface design of Legend of Heroes (3D)</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.facebook.com/mattt28?fref=ts">Mathew Martin</a> of Wireframe Sequence for 3D structures of Legend of Heroes and Asylum</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.facebook.com/chabs.coronacion?fref=ts">Chabs Coronacion</a> for 3D models and structures of Asylum</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.facebook.com/profile.php?id=100000132872872&fref=ts">Mj Castro</a> for 2D texture and graphic design of Asylum</div>
<div class="separator" style="clear: both; text-align: left;">
<a href="https://www.facebook.com/profile.php?id=100000132872872&fref=ts">Magz Hoho</a> for 2D textures and arts of Asylum</div>
<h2 style="text-align: left;">
3D Models</h2>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv5JOvKcENoB_wpr3YxwVOxtCd8YckDI6JkCbNgmCGwqdVAgZ3SKvhQIcpgGUvh5HHodlUome_Q75EbVQYhKfpIW5KXfqiTUa90hmT9Soe8Qry4W_yHhl_UTZrL0Nu56qF1p2zdvdz/s1600/autodesk+Maya+3d+female+character+1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv5JOvKcENoB_wpr3YxwVOxtCd8YckDI6JkCbNgmCGwqdVAgZ3SKvhQIcpgGUvh5HHodlUome_Q75EbVQYhKfpIW5KXfqiTUa90hmT9Soe8Qry4W_yHhl_UTZrL0Nu56qF1p2zdvdz/s1600/autodesk+Maya+3d+female+character+1.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5urEnnHn4k3z3l17HGYfGZtmrYBOg_sbFFbtiZksJB1LoYaS5V_tlrPTGOfgGxaFlDBEVXl6r2hyIXMLRHdkY27QWdS4D-ogdoJQvr-eMDlQqtcirbnrSKT1A8o4APbwrRJ2T2xyn/s1600/autodesk+Maya+3d+female+character.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5urEnnHn4k3z3l17HGYfGZtmrYBOg_sbFFbtiZksJB1LoYaS5V_tlrPTGOfgGxaFlDBEVXl6r2hyIXMLRHdkY27QWdS4D-ogdoJQvr-eMDlQqtcirbnrSKT1A8o4APbwrRJ2T2xyn/s1600/autodesk+Maya+3d+female+character.png" height="240" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRelZ38m6uMJEhWCdw9hKybjCKr_m_FoH55H2-TdRki6-KVdnxarBw64O6tK738IR4csTtYcR6kkufttqoWdB_Ez7lcOiW8YzBuyatB5Cmqb7m2GWJmvn2_vdSROigP2kxBndTLGqu/s1600/autodesk+Maya+3d+House+basic+Model.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRelZ38m6uMJEhWCdw9hKybjCKr_m_FoH55H2-TdRki6-KVdnxarBw64O6tK738IR4csTtYcR6kkufttqoWdB_Ez7lcOiW8YzBuyatB5Cmqb7m2GWJmvn2_vdSROigP2kxBndTLGqu/s1600/autodesk+Maya+3d+House+basic+Model.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbYvw_sZb1KAjWs_dXtrvfCKv4l2297mN48aOM2G36akh_2H3a5oOTYgWLkpufRe8Peb9ToFVBmbbUERzkaNIovNwGitj2L0nMkn3CcGon31dEHFa9VmJ8VJShn9fiGHCQS62F1StY/s1600/autodesk+Maya+3d+male+character+1wireframe.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbYvw_sZb1KAjWs_dXtrvfCKv4l2297mN48aOM2G36akh_2H3a5oOTYgWLkpufRe8Peb9ToFVBmbbUERzkaNIovNwGitj2L0nMkn3CcGon31dEHFa9VmJ8VJShn9fiGHCQS62F1StY/s1600/autodesk+Maya+3d+male+character+1wireframe.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyK-jI-f2xSQ3qNQh2tVP6DIzlWCAlrZJ2Bt16UPCu7wb0BinI7Bw5UnfB20U9XecJJ5Jo7lvjZTrYeZ8DjmEpUdSs9FT_rWMxI4Nbgu3_UwkuqegXqCaQo9L05lZhyphenhyphenPr-1_k4n2GG/s1600/autodesk+Maya+3d+male+character+2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyK-jI-f2xSQ3qNQh2tVP6DIzlWCAlrZJ2Bt16UPCu7wb0BinI7Bw5UnfB20U9XecJJ5Jo7lvjZTrYeZ8DjmEpUdSs9FT_rWMxI4Nbgu3_UwkuqegXqCaQo9L05lZhyphenhyphenPr-1_k4n2GG/s1600/autodesk+Maya+3d+male+character+2.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5OEqztL3v6J5keWkqfHKAy9vv9RuZBtQBepaCNMxu6nlGXooouXwXwAybo1AFCemYnYnJVAFYGtBmWZp_oYn-nvrJ084JzbT7r6XfXLIdPytSaBD8igE3Frb6TaGP5ZhZSj_Cp-5i/s1600/autodesk+Maya+3d+male+character+3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5OEqztL3v6J5keWkqfHKAy9vv9RuZBtQBepaCNMxu6nlGXooouXwXwAybo1AFCemYnYnJVAFYGtBmWZp_oYn-nvrJ084JzbT7r6XfXLIdPytSaBD8igE3Frb6TaGP5ZhZSj_Cp-5i/s1600/autodesk+Maya+3d+male+character+3.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDK_oxuWhmp9RL4AQf6Y0U0cTQ_OzvReCX_Npk8DIld7FJ4blWxKNcChQ_4bomaaetZRGc6K5SIBbj3fdobYkTMjULlMyGyoSwwZyramzAw1WAIsKIqxcYOGewEA_zUCpCIJ46_eD/s1600/autodesk+Maya+3d+male+character.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTDK_oxuWhmp9RL4AQf6Y0U0cTQ_OzvReCX_Npk8DIld7FJ4blWxKNcChQ_4bomaaetZRGc6K5SIBbj3fdobYkTMjULlMyGyoSwwZyramzAw1WAIsKIqxcYOGewEA_zUCpCIJ46_eD/s1600/autodesk+Maya+3d+male+character.png" height="179" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM839FFgpZ7jn8QiooXzrjH0-dyTgQymYIRuaBpuqfB5l6FI9FQ-lsc-6h_WTg3O8mfoSWtprYIU6YZfEVMlXFaJAXYyWKGDe4TZzZpJbAQ8fTMpBtsqr0KUIMqnTR1dcgaRBcTFgW/s1600/autodesk+Maya+3ds+max+simple+render+2.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM839FFgpZ7jn8QiooXzrjH0-dyTgQymYIRuaBpuqfB5l6FI9FQ-lsc-6h_WTg3O8mfoSWtprYIU6YZfEVMlXFaJAXYyWKGDe4TZzZpJbAQ8fTMpBtsqr0KUIMqnTR1dcgaRBcTFgW/s1600/autodesk+Maya+3ds+max+simple+render+2.jpg" height="240" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRdlSqOWQbHrurQmkSXMymjDoXuYxIFm7yqXdSkRyk0qF7BI6Yh1FvETJ67A8dJHd9Pvx8Q2O29GvkDEbQ-w0zt7baAgGTStmrEVTIQUTTRrO0vs_r4D8jIXbX-RBWEDe3cuYXdXN3/s1600/autodesk+Maya+3ds+max+simple+render.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRdlSqOWQbHrurQmkSXMymjDoXuYxIFm7yqXdSkRyk0qF7BI6Yh1FvETJ67A8dJHd9Pvx8Q2O29GvkDEbQ-w0zt7baAgGTStmrEVTIQUTTRrO0vs_r4D8jIXbX-RBWEDe3cuYXdXN3/s1600/autodesk+Maya+3ds+max+simple+render.jpg" height="240" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuQV1WTak9oa8ejcg9kicwtaZsA645Rt9L6TlGa3QUFzAXlYACRs_fScTNustO40I6nxfd-uclGcYqZMp_UkyKZhd7btHZcDv-nJgeo8ES3BRfuT-4i-qAkYhxi6uiARUC698OWEeu/s1600/autodesk+Maya+sample+character.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuQV1WTak9oa8ejcg9kicwtaZsA645Rt9L6TlGa3QUFzAXlYACRs_fScTNustO40I6nxfd-uclGcYqZMp_UkyKZhd7btHZcDv-nJgeo8ES3BRfuT-4i-qAkYhxi6uiARUC698OWEeu/s1600/autodesk+Maya+sample+character.png" height="180" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibaLm48OFhLSExupf0QV4rB_mlvrQvnMEpHbAbpwdV5slmdS9yDEnrWOAbcNip8Fh7lxpljraGmCnyJKAz9nYKAy6N9-NKN3MUiMseDnA6KZ8iFQtNcILrI9YY66K1BDXMgRVRSxTt/s1600/Male+Character+Protagonist+Autodesk+Maya.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibaLm48OFhLSExupf0QV4rB_mlvrQvnMEpHbAbpwdV5slmdS9yDEnrWOAbcNip8Fh7lxpljraGmCnyJKAz9nYKAy6N9-NKN3MUiMseDnA6KZ8iFQtNcILrI9YY66K1BDXMgRVRSxTt/s1600/Male+Character+Protagonist+Autodesk+Maya.png" height="180" width="320" /></a></div>
<h2 style="text-align: center;">
</h2>
<div style="text-align: left;">
<b>Websites/webpages</b></div>
<div style="text-align: left;">
<b><a href="http://nalimits.tk/">nalimits.tk</a> </b></div>
<div style="text-align: left;">
<b><a href="http://legendofheroes.tk/">legendofheroes.tk</a> </b></div>
<div style="text-align: left;">
<b><a href="http://istyle-project.tk/">istyle-project.tk</a> </b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Systems</b></div>
<div style="text-align: left;">
<br /></div>
<div style="text-align: left;">
<b>Loan System</b></div>
<div style="text-align: left;">
<b>SQLite Database Admin</b></div>
<div style="text-align: left;">
<b> </b></div>
<br /></div>
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-77652509777966647792013-12-21T07:13:00.001-08:002013-12-21T07:18:29.933-08:00Monkey GameAgain, I made a new game.<br />
It's for my classmate's project.<br />
I will put up a tutorial how to make this 2D game.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwDGgILztL-4XhtTKiUnSPjAAJddnjGxXOukxOsqABqgpAqP8TNbVnsbAoenBY2d-uh9txulviEA-9sbO_JJqU-3Klhv5GIONvQXhZ4cDn1q7mbBRFkVfReNNQNvyKyFov1Z_Ibg0r/s1600/monkey-game-2D-xna-program-parallax.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="239" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwDGgILztL-4XhtTKiUnSPjAAJddnjGxXOukxOsqABqgpAqP8TNbVnsbAoenBY2d-uh9txulviEA-9sbO_JJqU-3Klhv5GIONvQXhZ4cDn1q7mbBRFkVfReNNQNvyKyFov1Z_Ibg0r/s320/monkey-game-2D-xna-program-parallax.png" width="320" /></a></div>
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/16986751492483863295noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-56578084731487595632013-07-11T12:23:00.000-07:002013-08-07T16:44:14.050-07:00Flashing or Updating Firmware of Samsung Corby I<br />
In this tutorial, we will update the firmware of our samsung corby using the following tools and resources.<br />
<br />
<a href="http://www.4shared.com/file/TAf-S0eQ/MultiLoader_V556.html">Flasher</a><br />
<a href="http://www.mediafire.com/download/ogmzmgzdj5l/S3650XEIJ2.rar">Firmware <span style="background-color: white; color: #787878; font-family: 'Open Sans', sans-serif; font-size: 18px; line-height: 22px; white-space: nowrap;">S3650XEIJ2.rar</span></a><br />
<br />
Download the firmware and the flasher..<br />
<br />
This update will remove the lag in your samsung corby, and you will also be able to change the theme using patches. You can make your corby look like android etc.<br />
<br />
<br />
Now let's start,<br />
Back up all necessary files, contacts and messages because upon flashing the phone: files and data are erased. Turn your phone off.<br />
<br />
First remove your sim-card and memory card.<br />
Enter the phone download mode by pressing the following buttons at the same time.<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH1bcE4fggH6aTCNHaHhRkIvjD9zUTCOB3P6wIyAaD8Ak_rfm5fyI_D17MFg9ZoFwoDnH8K-1GVo8flTU01iP-std42-e5HaDhbt_h7BAKYUwyV1p7HFX4Lmrn5AuKHq_PDpFXVZU_I0Y/s1600/putting+samsung+corby+in+download+mode.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH1bcE4fggH6aTCNHaHhRkIvjD9zUTCOB3P6wIyAaD8Ak_rfm5fyI_D17MFg9ZoFwoDnH8K-1GVo8flTU01iP-std42-e5HaDhbt_h7BAKYUwyV1p7HFX4Lmrn5AuKHq_PDpFXVZU_I0Y/s320/putting+samsung+corby+in+download+mode.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Putting your phone in download Mode.</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;">Hold the Keys until the screen displays "download". </span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLFIcZLMKqWqTCx1RoDVNmo0Y-TB7pR4vWGkWujEjFIfHtyL5657bi_CoA_oj1eB0N90D5KjhcpmCmsAw6r9ZEDvjP-fFJIgx4ka96YC0LO0qP-khcWvAvzyYPM-iRi9pRHj-U_b4Wih0/s1600/Samsung+Corby+Download+Mode.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLFIcZLMKqWqTCx1RoDVNmo0Y-TB7pR4vWGkWujEjFIfHtyL5657bi_CoA_oj1eB0N90D5KjhcpmCmsAw6r9ZEDvjP-fFJIgx4ka96YC0LO0qP-khcWvAvzyYPM-iRi9pRHj-U_b4Wih0/s320/Samsung+Corby+Download+Mode.jpg" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Download mode of samsung corby, ready for flashing and updating.</td></tr>
</tbody></table>
<br />
Next extract the resources in your computer (firmware), open Multiloader and connect your phone using an USB Cable. Set up the phone resources path..<br />
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdT9yRCueTlZTcTlkG4GwC3AQF90_5RgGSPKSxTpkn16NTkbWbSEDw8NOJ7jfbzV8ZoyfrnbHlDhiMfZw-y-fJu0B7DpRw8r-xUn8CEe1jsSopQ9cu8GXQXXAauTwAKsPGbhcmo5VGY1s/s1600/Setting+up+multiloader+for+flashing+or+updating+samsung+corby+firmware.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdT9yRCueTlZTcTlkG4GwC3AQF90_5RgGSPKSxTpkn16NTkbWbSEDw8NOJ7jfbzV8ZoyfrnbHlDhiMfZw-y-fJu0B7DpRw8r-xUn8CEe1jsSopQ9cu8GXQXXAauTwAKsPGbhcmo5VGY1s/s320/Setting+up+multiloader+for+flashing+or+updating+samsung+corby+firmware.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Setting up multiloader for flashing or updating samsung corby firmware</td></tr>
</tbody></table>
<br />
Upon Port Search, it should look like this..<br />
<div>
If no results are shown in the port connections, open your phone. Go to settings and in PC Connections, Select Media Player mode. Then Put your phone again in download mode</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: #cc0000;">(If multiloader can't detect your phone, install the driver by downloading and installing this </span><a href="http://downloadcenter.samsung.com/content/SW/200912/20091222200116203/New_PC_Studio_1.5.1.10064_2.exe"><span style="color: black;">New_PC_Studio_1.5.1.10064_2</span><span style="color: white;">.exe</span></a><span style="color: #cc0000;">, After installing, open your phone. Go to settings and in PC Connections, Select Samsung PC Studio mode. Then Put your phone again in download mode)</span></div>
<div>
<span style="color: #cc0000;"><br /></span></div>
<div>
<span style="color: #cc0000;"><br /></span></div>
<div>
Select the port which is ready, then click download..</div>
<div>
<br /></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqAA9XYUuP_oPc9vFZT_YskG3FAKpC8ml6sdi9xpavDr1n9OXmTuEZiD6_iS5NjaPBUt4LGepz6FmFq7iQOL8mTQVLdB2ZrVnPPXX2wJCfTOupisppsCIEoEo1DJYlTuH51nO3uHseKF8/s1600/Flashing+or+updating+Firmware+of+samsung+Corby+using+multiloader.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqAA9XYUuP_oPc9vFZT_YskG3FAKpC8ml6sdi9xpavDr1n9OXmTuEZiD6_iS5NjaPBUt4LGepz6FmFq7iQOL8mTQVLdB2ZrVnPPXX2wJCfTOupisppsCIEoEo1DJYlTuH51nO3uHseKF8/s320/Flashing+or+updating+Firmware+of+samsung+Corby+using+multiloader.png" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Flashing or updating Firmware of samsung Corby using multiloader</td></tr>
</tbody></table>
Wait for few minutes, Messages and progress will be seen at the left part of the multiloader. If all Files are complete. The phone will automatically start, check your phone.. You can now use android themes for your phone.<br />
<div>
<br /></div>
<div>
<br /></div>
<div>
Example of a android patched corby </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUkuusUn4NfPf6JT9PldHxWYlIxRxpPBAMC62Kxd_t4p5-cwAlAvDw_pM2YfT66pwWkYJ_U0fXtLr9d_VEPkRJKgaQjs72-iOOSU4md_B3Zx1zAiPgcgI3baRmE6KaxQH07LvV80B6pks/s1600/Samsung+Corby+running+on+android+Theme+main+menu.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUkuusUn4NfPf6JT9PldHxWYlIxRxpPBAMC62Kxd_t4p5-cwAlAvDw_pM2YfT66pwWkYJ_U0fXtLr9d_VEPkRJKgaQjs72-iOOSU4md_B3Zx1zAiPgcgI3baRmE6KaxQH07LvV80B6pks/s320/Samsung+Corby+running+on+android+Theme+main+menu.jpg" width="240" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtSbQ3JI4FTr7WFHkF7hVHf3nM9Lz0cqFRNVnhfu9JpEN3aH0zZY5fMK43tjbSk8hmENG7KMZmrcPPSEIvVmO7XDwy84lqYvsw9uZvfNBOTGHHVqc9BNE_k_K1pQcCCm8ZDLRfXEuipx4/s1600/Samsung+Corby+running+on+android+Theme.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtSbQ3JI4FTr7WFHkF7hVHf3nM9Lz0cqFRNVnhfu9JpEN3aH0zZY5fMK43tjbSk8hmENG7KMZmrcPPSEIvVmO7XDwy84lqYvsw9uZvfNBOTGHHVqc9BNE_k_K1pQcCCm8ZDLRfXEuipx4/s320/Samsung+Corby+running+on+android+Theme.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<br /></div>
<div style="text-align: center;">
Tutorials for patching will be post soon HERE</div>
<div>
<br /></div>
<div>
<br />
<div>
<br /></div>
<div>
<div>
<br />
<div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<br />
<br />
<br />
<br /></div>
</div>
</div>
</div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-57598641840224761192013-07-11T11:35:00.000-07:002013-08-07T16:44:14.052-07:00How to update firmware of Samsung Corby gt-s3653<br />
<br />
If you want to update your Samsung corby gt-s3653, the following steps are required to do.<br />
This update will remove some lag issues in corby.<br />
<br />
<br />
First turn back-up all your files such as contacts, messages, sound files, video files etc.<br />
Then remove the sim-card and memory card attached at the back of your phone..<br />
Turn it on, go to the dialer or keypad: type this code.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0rRZc42HCuuOBJTe_mpLjAGBKQgSJQAln-6EC-aQ-qWkSVxxVU8asp5H8jjJHVqj359vXThjnOMoxDTJS4e1NMrqGHe6m712sVmTfbck5HL9DuLra6ZEEdH5zOegVIKG7af9kqZbaO1s/s1600/How+to+know+the+firmware+version+of+samsung+corby+s3653w+by+using+code.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0rRZc42HCuuOBJTe_mpLjAGBKQgSJQAln-6EC-aQ-qWkSVxxVU8asp5H8jjJHVqj359vXThjnOMoxDTJS4e1NMrqGHe6m712sVmTfbck5HL9DuLra6ZEEdH5zOegVIKG7af9kqZbaO1s/s320/How+to+know+the+firmware+version+of+samsung+corby+s3653w+by+using+code.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Code for getting the version of firmware in Samsung Corby s3653w/s3650</td></tr>
</tbody></table>
*#1234# - this code will get the current version of firmware the phone is using..<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB7fgPP_Tf4z3G9-Alcywkt-kF_XaouXd3oUT8iIZZPs_kDjbKyzxEaYzBbM51G8a-i37MUl76j1yKR4gfWiU3sAbyCfaQWTdjvVy8sjru_PBmNCcvW34w9ntO-WMX_OgirARHwsLDs4w/s1600/How+to+know+the+firmware+version+of+samsung+corby+s3653w+f.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjB7fgPP_Tf4z3G9-Alcywkt-kF_XaouXd3oUT8iIZZPs_kDjbKyzxEaYzBbM51G8a-i37MUl76j1yKR4gfWiU3sAbyCfaQWTdjvVy8sjru_PBmNCcvW34w9ntO-WMX_OgirARHwsLDs4w/s320/How+to+know+the+firmware+version+of+samsung+corby+s3653w+f.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Checking the version of firmware in samsung corby s3653w/s3650</td></tr>
</tbody></table>
Then exit..<br />
<br />
<br />
<br />
Now to update your phone's firmware, Go to your dialer/keypad again, type the command that will execute auto update.<br />
<br />
*#2665# - This line will open the option for updating firmware, next tap 1 then confirm..<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhALzPWBVpKdQu0FXpHAt_wXXw23mhYfw1AKlS77nZTEZ4uayCBgcd3e6NneTMvneEXKc2kYXhWDwVuCK3AE4Aa1KXwU0PbdORVvMsOr-p7AfRIupTtWu52rFrbMLZuiHUj15dKocq7Wh4/s1600/Updating+the+firmware+of+corby+samsung+s3653+-+s3650.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhALzPWBVpKdQu0FXpHAt_wXXw23mhYfw1AKlS77nZTEZ4uayCBgcd3e6NneTMvneEXKc2kYXhWDwVuCK3AE4Aa1KXwU0PbdORVvMsOr-p7AfRIupTtWu52rFrbMLZuiHUj15dKocq7Wh4/s320/Updating+the+firmware+of+corby+samsung+s3653+-+s3650.jpg" width="240" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Updating the firmware of corby</td></tr>
</tbody></table>
<br />
<br />
<br />
Wait for few seconds, if it's succeed. Type *#1234# again to check if the firmware changed. If not try again..<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-55348986148883826182013-07-06T08:05:00.002-07:002013-07-06T18:29:24.780-07:00XNA 3D Simple Collision Detection with BoundingSphere<br />
<br />
First declare a Model for the 3ds max object you want to use..<br />
<br />
Model 3dsMaxModel, 3dsMaxHouseModel;<br />
Vector3 ModelPosition, housePosition;<br />
<br />
<br />
In your load content..<br />
<br />
//SET THE MODEL INTO THE VARIABLES<br />
3dsMaxModel = Content.Load<model>("ModelName");</model><br />
3dsMaxHouseModel= Content.Load<model>("ModelName");</model><br />
//SET THE POSITION<br />
ModelPosition = Vector3.Zero;<br />
housePosition = new Vector3(10,1,10);<br />
<br />
<br />
Create a new method for checking the collision<br />
The method will use 4 variables, it is pretty much self explanatory.<br />
public void CollisionTest(Model _model1, Model _model2, Vector3 _model1Position, Vector3 _model2Position){<br />
//Create a new bounding sphere for the first model..<br />
<br />
BoundingSphere obj = _model1.Meshes[0].BoundingSphere; // Get the bounding sphere for the mesh<br />
obj.Center = _model1Position; //SETS the center of the bounding sphere<br />
<br />
//For the second object..<br />
BoundingSphere obj2 = _model2.Meshes[0].BoundingSphere;<br />
obj2.Center = _model2Position;<br />
<br />
if(obj.Intersects(obj2)){<br />
//DO SOMETHING, This is where we are gonna code what happens to the model when it intersects with another model<br />
}<br />
}<br />
<br />
<br />
And be sure to put use the CollisionTest in your update method..<br />
<br />
CollisionTest(3dsMaxModel,3dsMaxHouseModel,ModelPosition,housePosition);<br />
<div>
<br /></div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-58830714291997627712013-07-01T11:38:00.000-07:002013-07-02T01:38:45.424-07:00VII. Improve our tank game - Additional Updates XNALet's add additional updates in this project.<br />
Open your project and locate the AI.(gameTime);<br />
We don't want the AI to move when we're already dead , or the AI is dead. So, set a condition before updating the AI<br />
<br />
<span style="color: #6aa84f;">//UPDATE METHOD</span><br />
<span style="color: #45818e;">if (enemy.alive && player.alive)</span><br />
<span style="color: #45818e;">{</span><br />
<span style="color: #45818e;"> AI(gameTime);</span><br />
<span style="color: #45818e;">}</span><br />
<br />
Next, add a bool to your project called hasstart.<br />
<span style="color: #45818e;"> bool hasstart = false;</span><br />
<span style="color: #45818e;"><br /></span>
Next go to your Game ()method, make the screen larger for more gameplay space.<br />
<span style="color: #45818e;"> public Game1()</span><br />
<span style="color: #45818e;"> {</span><br />
<span style="color: #45818e;"> graphics = new GraphicsDeviceManager(this);</span><br />
<span style="color: #45818e;"> Content.RootDirectory = "Content";</span><br />
<span style="color: #45818e;"> graphics.PreferredBackBufferHeight = 768;</span><br />
<span style="color: #45818e;"> graphics.PreferredBackBufferWidth = 1024;</span><br />
<span style="color: #45818e;"> graphics.ApplyChanges();</span><br />
<span style="color: #45818e;"> }</span><br />
<br />
<span style="color: #6aa84f;">//UPDATE METHOD</span><br />
<span style="color: #45818e;"> </span> <span style="font-size: x-small;"><span style="color: #cc0000;"> if (hasstart) </span><span style="color: #6aa84f;">//IF THE GAME HAS STARTED, UPDATE THE GAME OBJECTS, METHODS AND THE GAME</span></span><br />
<span style="color: #cc0000; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> updateTank();</span><br />
<span style="color: #45818e; font-size: x-small;"> if (enemy.alive && player .alive )</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> AI(gameTime);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (player.alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> tempposition = player.position;</span><br />
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> player.rotation += 0.1f;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> player.rotation -= 0.1f;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Up) && oldKeyboardState.IsKeyDown(Keys.Up))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position += player.velocity * moveSpeed;</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"> soundManager.soundBank.PlayCue("move");</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Down) && oldKeyboardState.IsKeyDown(Keys.Down))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> player.position -= player.velocity * moveSpeed;</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Space) && oldKeyboardState.IsKeyUp(Keys.Space))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> fireBullets();</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> if (enemy.life <= 0)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> enemy.alive = false;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> if (player.life <= 0)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> player.alive = false;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> detectCollisionsAgainstObject(player, enemy);</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><span style="color: #cc0000; font-size: x-small;"> }</span><br />
<span style="color: #cc0000; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Enter) && oldKeyboardState.IsKeyUp(Keys.Enter) && hasstart == false)</span><br />
<span style="color: #cc0000; font-size: x-small;"> {</span><br />
<span style="color: #cc0000; font-size: x-small;"> </span><span style="color: #6aa84f; font-size: x-small;">//IF THE PLAYER PRESSED ENTER KEY AND THE GAME HASNT STARTED , SET THE GAME TO START</span><br />
<span style="color: #cc0000; font-size: x-small;"> hasstart = true;</span><br />
<span style="color: #cc0000; font-size: x-small;"> }</span><br />
<span style="color: #cc0000; font-size: x-small;"><br /></span>
<span style="color: #cc0000; font-size: x-small;"><br /></span>
NEXT, INFORM THE USER HOW TO START THE GAME<br />
<span style="color: #6aa84f;">//DRAW METHOD, EDIT YOUR DRAW METHOD</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"> <span style="color: #45818e;">protected override void Draw(GameTime gameTime)</span></span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> GraphicsDevice.Clear(Color.CornflowerBlue);</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Begin();</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(background , Vector2 .Zero ,</span><br />
<span style="color: #45818e; font-size: x-small;"> null, Color.White, 0f,</span><br />
<span style="color: #45818e; font-size: x-small;"> Vector2 .Zero ,</span><br />
<span style="color: #45818e; font-size: x-small;"> 2f, SpriteEffects.None, 0);</span><br />
<span style="color: #45818e; font-size: x-small;"> if (enemy.alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(enemy.texture, enemy.position,</span><br />
<span style="color: #45818e; font-size: x-small;"> null, Color.White, enemy.rotation,</span><br />
<span style="color: #45818e; font-size: x-small;"> new Vector2(enemy.texture.Width / 2, enemy.texture.Height / 2),</span><br />
<span style="color: #45818e; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> else</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "YOU WIN!: ", new Vector2(GraphicsDevice.Viewport.Width / 2-14, GraphicsDevice.Viewport.Height / 2), Color.Red);</spritefont></span><br />
<span style="color: #cc0000; font-size: x-small;">hasstart= false;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> SpriteFont font = Content.Load<spritefont>("font");</spritefont></span><br />
<span style="color: #45818e; font-size: x-small;"> </span><span style="color: #cc0000; font-size: x-small;"> if(!hasstart )</span><br />
<span style="color: #cc0000; font-size: x-small;"> spriteBatch.DrawString(font, "PRESS ENTER TO START GAME", new Vector2(GraphicsDevice.Viewport.Width / 2 - font.MeasureString("PRESS ENTER TO START GAME").X / 2, GraphicsDevice.Viewport.Height / 2), Color.White);</span><br />
<span style="color: #cc0000; font-size: x-small;"> </span><br />
<span style="color: #45818e; font-size: x-small;"> if (player.alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(player.texture, player.position,</span><br />
<span style="color: #45818e; font-size: x-small;"> null, Color.White, player.rotation,</span><br />
<span style="color: #45818e; font-size: x-small;"> new Vector2(player.texture.Width / 2, player.texture.Height / 2), 0.5f, SpriteEffects.None, 0);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> else</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "GAME OVER!: ", new Vector2 (GraphicsDevice .Viewport .Width /2 -14, GraphicsDevice .Viewport .Height /2),Color.Red);</spritefont></span><br />
<span style="color: #cc0000; font-size: x-small;">hasstart = false;</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> updateBullets();</span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "BULLETS: " + player.numberOfBullets.ToString() + " " + player .rotation .ToString (), Vector2.Zero, Color.White);</spritefont></span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "ENEMY LIFE: " + enemy.life.ToString(),</spritefont></span><br />
<span style="color: #45818e; font-size: x-small;"> new Vector2(GraphicsDevice .Viewport .Width - 200 ,0), Color.White);</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.End();</span><br />
<span style="color: #45818e; font-size: x-small;"> foreach (gameObject explode in Explosion)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> drawExplosion(explode);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> base.Draw(gameTime);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><br />
<br />
NOW CREATE A RECTANGLE METHOD THAT WILL DRAW THE LIFE OF THE PLAYER<br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"> <span style="color: #45818e;"> public Rectangle life(Vector2 position, int hp, int border )</span></span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><br />
<span style="color: #45818e; font-size: x-small;"> int w = 1;</span><br />
<span style="color: #45818e; font-size: x-small;"> int h = 10;</span><br />
<span style="color: #45818e; font-size: x-small;"> return new Rectangle((int)position.X - border , (int)position.Y - border , w * hp +border *2 ,h + border*2 );</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> public void drawRectangle(bool alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> Color hpColor;</span><br />
<span style="color: #45818e; font-size: x-small;"> if (alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> if (player.life < 30)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> hpColor = Color.Red;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> else</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> hpColor = Color.ForestGreen;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> Texture2D bounds = new Texture2D(GraphicsDevice, 1, 2);</span><br />
<span style="color: #45818e; font-size: x-small;"> Color[] color = new Color[1 * 2];</span><br />
<span style="color: #45818e; font-size: x-small;"> for (int i = 0; i < color.Length; i++)</span><br />
<span style="color: #45818e; font-size: x-small;"> color[i] = Color.Black * 0.5f;</span><br />
<span style="color: #45818e; font-size: x-small;"> bounds.SetData<color>(color);</color></span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(bounds, life(new Vector2(player.position.X - player.texture.Width / 4, player.position.Y - player.texture.Height / 3), 100, 2), Color.White);</span><br />
<span style="color: #45818e; font-size: x-small;"> bounds = new Texture2D(GraphicsDevice, 1, 1);</span><br />
<span style="color: #45818e; font-size: x-small;"> bounds.SetData<color>(new Color[] { hpColor });</color></span><br />
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(bounds, life(new Vector2(player.position.X - player.texture.Width / 4, player.position.Y - player.texture.Height / 3), player.life, 0), Color.White);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"></span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e;"><br /></span>
THEN ADD IT TO YOUR DRAW METHOD<br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><span style="color: #45818e;"> drawRectangle(player .alive ); </span><span style="color: #6aa84f;">//PLACE IT BEFORE THE SPRITEBATCH.END</span></span><br />
<span style="font-size: x-small;"><span style="color: #6aa84f;"><br /></span></span>
<span style="font-size: x-small;"><span style="color: #6aa84f;"><br /></span></span>
<span style="font-size: x-small;"><span style="color: #6aa84f;"><br /></span></span>
RUN THE GAME!!<br />
<span style="font-size: x-small;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjswVl1tjhyphenhyphenJCkMZ8OYFXbXcxgYcqP-hqZvVvNyOsM5kDfIuoSCGWK44XlgPQhBaNpmxRQshwta2E_iIUQdACO1vApPOca8Wzf-W_vcsmE36BMj4maQppWh3bZutqQ3x8lR-NhuvyA90Mk/s1039/xna+game+statemanagement+-+game+has+ended.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="234" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjswVl1tjhyphenhyphenJCkMZ8OYFXbXcxgYcqP-hqZvVvNyOsM5kDfIuoSCGWK44XlgPQhBaNpmxRQshwta2E_iIUQdACO1vApPOca8Wzf-W_vcsmE36BMj4maQppWh3bZutqQ3x8lR-NhuvyA90Mk/s320/xna+game+statemanagement+-+game+has+ended.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[AI WONT UPDATE : PLAYER IS DEAD]</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuEhu6rnTAORMjf1LHnnCZgqA5FzhIS_xoGdiYZSit0ODVAd1WOBA5iTSd8qh8V22NU21zZtcqXPiMxFfmEtCl532OW72wnv7yCgtS5ZlKZzo7XhWH0BIT35s859eQZzkgKTxpJoCmXVU/s1049/xna+game+statemanagement+-+wait+for+input.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="231" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuEhu6rnTAORMjf1LHnnCZgqA5FzhIS_xoGdiYZSit0ODVAd1WOBA5iTSd8qh8V22NU21zZtcqXPiMxFfmEtCl532OW72wnv7yCgtS5ZlKZzo7XhWH0BIT35s859eQZzkgKTxpJoCmXVU/s320/xna+game+statemanagement+-+wait+for+input.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[WAIT FOR INPUT DEPENDING ON HAS START BOOL]</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS-uwy1Q4mkrLRUyD4uvj7go4v_sDxw5e35sR-6g9Eda2TGOKL_FCgKIDkHpd8RA-ZlSTz00j3FRt8Gy2Lw0asqOYhG8-NszFKiVB_WjikUx54T1aiw20gOVot2qTtgAlnxaHHMiuURd0/s1061/xna+tank+game+-+HP+rectangle.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="229" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS-uwy1Q4mkrLRUyD4uvj7go4v_sDxw5e35sR-6g9Eda2TGOKL_FCgKIDkHpd8RA-ZlSTz00j3FRt8Gy2Lw0asqOYhG8-NszFKiVB_WjikUx54T1aiw20gOVot2qTtgAlnxaHHMiuURd0/s320/xna+tank+game+-+HP+rectangle.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[HP BAR USING RECTANGLE METHOD]</div>
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><br /></span>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-3214690290093893462013-07-01T01:15:00.000-07:002013-07-01T04:41:30.355-07:00VII. Improve our tank game - Adding Sound Files<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDEH8rE5f9j4HKCGDQhzp-x7n2twYGHyT2DTsdEMOHjRs_84lEBr4RL5nT0uObLhb-ziutffryb_V8AVNXFQ8cy5Rqj4PrO8r6kpPhUvT4rhL5qjyzA_NiSfoTILleK6_ew4P3o3H_ojY/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDEH8rE5f9j4HKCGDQhzp-x7n2twYGHyT2DTsdEMOHjRs_84lEBr4RL5nT0uObLhb-ziutffryb_V8AVNXFQ8cy5Rqj4PrO8r6kpPhUvT4rhL5qjyzA_NiSfoTILleK6_ew4P3o3H_ojY/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #e06666;">This topic is the continuation of the my previous 2D tutorial, Click</span> <a href="http://bit.ly/14jNrkR">Here</a> <span style="color: #e06666;">to go to the main post.</span>]</div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #e06666;">How to create and use XACT audio File - To upload soon</span>]</div>
<div class="separator" style="clear: both; text-align: left;">
We're going to add a new class called soundManager, in your solution explorer. Add a new class name it soundManager.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Paste the following Codes inside the class, make sure the namespace is same with your Game1.cs namespace.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
To use this class, we need the ff packages</div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using System;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using System.Collections.Generic;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Audio;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Content;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Input;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">namespace tankGame</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">{</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> class soundManager</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> </span><span style="color: #6aa84f; font-size: x-small;"> //Creates soundManager class methods, variables</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public AudioEngine audioEngine; </span><span style="color: #6aa84f; font-size: x-small;">//The engine that plays the sound.</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public WaveBank waveBank;</span><span style="color: #6aa84f; font-size: x-small;"> //A collection of waves</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public Cue engineSound = null;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public SoundBank soundBank; </span><span style="color: #6aa84f; font-size: x-small;">//A collection of Sounds</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public soundManager()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public void loadcontent(ContentManager content)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> audioEngine = new AudioEngine("Content/Audio/sound.xgs"); </span><span style="color: #6aa84f; font-size: x-small;">//Set's the location of the compiled XACT(xgs extension)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> waveBank = new WaveBank(audioEngine, "Content/Audio/Wave Bank.xwb"); </span><span style="color: #6aa84f; font-size: x-small;">//Compiled waveback (xwb extension)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> soundBank = new SoundBank(audioEngine, "Content/Audio/Sound Bank.xsb");</span><span style="color: #6aa84f; font-size: x-small;">//Compiled SoundBound(xsb)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> public void Update(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> audioEngine.Update(); </span><span style="color: #6aa84f; font-size: x-small;">//UPDATES THE SOUND ENGINE</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> } </span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;">}</span></div>
<div class="separator" style="clear: both; text-align: left;">
To use this class, you must have a XACT FILE, a wavebank and soundbank which are within the xact file.</div>
<div class="separator" style="clear: both; text-align: left;">
We successfully created a class that will play different sounds depending on input, what we need to do is to download and import the sound file(XACT) on our game content. To do this..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Download and unzip this on your game content..</div>
<div class="separator" style="clear: both; text-align: left;">
[<a href="https://bit.ly/12gcRN2">Click Here</a>]</div>
<div class="separator" style="clear: both; text-align: left;">
Next go to your game content, to know your game content: View the attached image.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFtYHiP7fboSW8bSs1WQAi4zNxQSrYwP8VXKLACwEZ4FwpcmVsOFptb4viOnRQEZvBkGDHQakDYFdtfq-Pwyh_u_JJbO0N_FBtueSieuVYqcYh1Su6Po3U61Hqcnjtu9CI5-82_oI9u4M/s470/adding+audio+files+to+your+xna+game+content.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFtYHiP7fboSW8bSs1WQAi4zNxQSrYwP8VXKLACwEZ4FwpcmVsOFptb4viOnRQEZvBkGDHQakDYFdtfq-Pwyh_u_JJbO0N_FBtueSieuVYqcYh1Su6Po3U61Hqcnjtu9CI5-82_oI9u4M/s320/adding+audio+files+to+your+xna+game+content.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #cc0000;">Copy and paste the rar file> Extract Here</span>]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoMvooKzKxec7gaZd3rauarQTePxx4W509_DwuxKw8rwJYzUbvqasn-6mLw24X0ENehYhGh_8X8rZJMwzykWtadxZlUBmEAOObVfMZJN-hcE9tVc5J40L4ZF0wysqtaHNVB_B0uqhwNw/s816/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXoMvooKzKxec7gaZd3rauarQTePxx4W509_DwuxKw8rwJYzUbvqasn-6mLw24X0ENehYhGh_8X8rZJMwzykWtadxZlUBmEAOObVfMZJN-hcE9tVc5J40L4ZF0wysqtaHNVB_B0uqhwNw/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #cc0000;">Add a folder called Audio Then import the sound files</span>]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZoevwkqhdUmfOYvm8maBswfO6kXlK6fO8FRByewMrBnK73Rtht-MieUIqSWy-v9dXXW2DMNpyiEGGBFOaXSSMCCLWVvZnLf-Up3seOoANzJ8TrBuDJQYcg3gKD7tz47pLHILTuxJYE48/s611/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="183" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZoevwkqhdUmfOYvm8maBswfO6kXlK6fO8FRByewMrBnK73Rtht-MieUIqSWy-v9dXXW2DMNpyiEGGBFOaXSSMCCLWVvZnLf-Up3seOoANzJ8TrBuDJQYcg3gKD7tz47pLHILTuxJYE48/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #cc0000;">Import it to the game. Add > existing item> browse to your game Content</span>]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6IM3oWET7fHR0tOiumV7w8pN0pqEi8NvEiN2nxZPvs4dvSk00NSHGB8wO6BKSLgMp-XRNvVUm6Rw3CViU3IUsNlQZyqtz61fV3qf3TwHkq54IcZI5_uSBveRjC0Hlw5JkO9PXnD6yFy0/s675/Changing+the+properties+of+your+asset.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6IM3oWET7fHR0tOiumV7w8pN0pqEi8NvEiN2nxZPvs4dvSk00NSHGB8wO6BKSLgMp-XRNvVUm6Rw3CViU3IUsNlQZyqtz61fV3qf3TwHkq54IcZI5_uSBveRjC0Hlw5JkO9PXnD6yFy0/s320/Changing+the+properties+of+your+asset.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #cc0000;">After importing, On your properties:Select all the imported files and set Copy to output Directory : Copy always</span>]</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSfpTmjt734HbtXIs3an-0FwRqojZXhQ1gXjHf7_KKM4X9LSpx9dVmHI_oiiah6HTpGp9ybUzIcwQuHqyax3H2gt4Qh1Ow0eqIDgyo9MzohvrCxMh281g9KOfCrZ2p4PKRMrKx9aFhXj8/s675/Changing+the+Build+Action+property++of+your+asset.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSfpTmjt734HbtXIs3an-0FwRqojZXhQ1gXjHf7_KKM4X9LSpx9dVmHI_oiiah6HTpGp9ybUzIcwQuHqyax3H2gt4Qh1Ow0eqIDgyo9MzohvrCxMh281g9KOfCrZ2p4PKRMrKx9aFhXj8/s320/Changing+the+Build+Action+property++of+your+asset.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
[<span style="color: #cc0000;">Change the property of the XACT file("</span>sound<span style="color: #cc0000;">"), XACT FILES NEED TO BE COMPILED. Set the Build action to Compile</span>]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
After this run the game. The game will automatically compile the xact file to xgs format. The wavebank will be complied to xwb and the soundbank will be compiled to xsb.</div>
<div class="separator" style="clear: both; text-align: left;">
Now we cleared all the conditions to use the sound manager class. </div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
GO TO YOUR Game1.cs, declare a soundManager at the top of the class.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;">soundManager soundManager;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
On our loadContent method, we need to set soundmanager as new soundmanager then load the content of the soundmanager class..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> soundManager = new soundManager(); </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> soundManager.loadcontent(this.Content ); </span><span style="color: #6aa84f;">// passes the Contentmanager of the game and loads the soundmanager class resources.</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> soundManager.soundBank.PlayCue("BGM"); </span><span style="color: #6aa84f;">//PLAYS THE BGM CUE, the cues are made upon creating a xact file. Which means, you need to open the Xact file then click soundBank to see the cue names on it.</span></div>
<br />
In this xact file that you downloaded, there are 4 cues i made.<br />
"BGM" = background music.<br />
"fire" = sound effect for firing bullets.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
"move" = sound effect for moving tanks.<br />
"explosion" = sound effect to give impact to the explosion methods.<br />
<br />
<br />
Using the fire cue - goto to our fireBullets and fireAIBullets, add the line to play the fire cue whenever we fire a bullet..<br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"> <span style="color: #45818e;">private void fireBullets()</span></span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> if (player.numberOfBullets > 0)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> gameObject bulletFire = new gameObject();</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.alive = true;</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.rotation = player.rotation;</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.position = new Vector2(player.position.X + bulletFire.velocity.X * 100,</span><br />
<span style="color: #45818e; font-size: x-small;"> player.position.Y + bulletFire.velocity.Y * 100);</span><br />
<span style="color: #45818e; font-size: x-small;"> bullet.Add(bulletFire);</span><br />
<span style="color: #45818e; font-size: x-small;"> player.numberOfBullets--;</span><br />
<span style="color: #cc0000; font-size: x-small;"> soundManager.soundBank.PlayCue("fire");</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> private void fireAIBullets()</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> if (enemy.numberOfBullets > 0)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> gameObject bulletFire = new gameObject();</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.alive = true;</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.rotation = enemy.rotation;</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletFire.position = new Vector2(enemy.position.X + enemy.velocity.X * 100,</span><br />
<span style="color: #45818e; font-size: x-small;"> enemy.position.Y + bulletFire.velocity.Y * 100);</span><br />
<span style="color: #45818e; font-size: x-small;"> bullet.Add(bulletFire);</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><span style="color: #cc0000; font-size: x-small;">soundManager.soundBank.PlayCue("fire");</span><br />
<span style="color: #45818e; font-size: x-small;"> enemy.numberOfBullets--;</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"><br /></span>
<span style="color: #45818e; font-size: x-small;"><br /></span>
Using the explosion cue - goto detect collision and play the explosion cue when collisions are detected<br />
<span style="color: #45818e; font-size: x-small;"> private void detectCollisions(gameObject _bullets, gameObject _gameObject){</span><br />
<span style="color: #45818e; font-size: x-small;"> Vector2 origin, origin1;</span><br />
<span style="color: #45818e; font-size: x-small;"> origin = new Vector2(_bullets.texture.Width / 4, _bullets.texture.Height / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"> origin1 = new Vector2(_gameObject.texture.Width / 4, _gameObject.texture.Height / 4);</span><br />
<span style="color: #45818e; font-size: x-small;"> BoundingBox bulletBounds = new BoundingBox();</span><br />
<span style="color: #45818e; font-size: x-small;"> BoundingBox Player = new BoundingBox();</span><br />
<span style="color: #45818e; font-size: x-small;"> Player.Min = new Vector3(_gameObject.position.X - origin1 .X ,</span><br />
<span style="color: #45818e; font-size: x-small;"> _gameObject.position.Y - origin1.Y, 1f);</span><br />
<span style="color: #45818e; font-size: x-small;"> Player.Max = new Vector3(origin1.X /2+ _gameObject .position .X ,</span><br />
<span style="color: #45818e; font-size: x-small;"> origin1.Y + _gameObject.position.Y, 1f);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletBounds.Min = new Vector3(_bullets.position.X - origin.X ,</span><br />
<span style="color: #45818e; font-size: x-small;"> _bullets.position.Y-origin.Y , 1f);</span><br />
<span style="color: #45818e; font-size: x-small;"> bulletBounds.Max = new Vector3(origin.X /2 + _bullets.position.X,</span><br />
<span style="color: #45818e; font-size: x-small;"> origin.Y + _bullets.position.Y, 1f);</span><br />
<span style="color: #45818e; font-size: x-small;"> if (_bullets.alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> if (_gameObject.alive)</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> if (Player.Intersects(bulletBounds))</span><br />
<span style="color: #45818e; font-size: x-small;"> {</span><br />
<span style="color: #45818e; font-size: x-small;"> _bullets.alive = false;</span><br />
<span style="color: #45818e; font-size: x-small;"> _gameObject.life -= 5;</span><br />
<span style="color: #45818e; font-size: x-small;"> </span><span style="color: #cc0000; font-size: x-small;">soundManager.soundBank.PlayCue("explosion");</span><br />
<span style="color: #45818e; font-size: x-small;"> addExplosions(_bullets);</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<span style="color: #45818e; font-size: x-small;"> }</span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Using the move cue- go to your update method.</div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">if (currentKeyboardState.IsKeyDown(Keys.Up) && oldKeyboardState.IsKeyDown(Keys.Up))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position += player.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span><span style="color: #cc0000; font-size: x-small;"> soundManager.soundBank.PlayCue("move");</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Down) && oldKeyboardState.IsKeyDown(Keys.Down))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position -= player.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> soundManager.soundBank.PlayCue("move");</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
ALSO PLAY MOVE CUE WHEN AI IS MOVING.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> private void AI(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> Random r = new Random();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float x = player.position.X - enemy.position.X;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float y = player.position.Y - enemy.position.Y;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float desiredAngle = (float)Math.Atan2(y, x);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.rotation = desiredAngle;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.velocity.X = (float)Math.Cos(enemy.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.velocity.Y = (float)Math.Sin(enemy.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (gameTime.TotalGameTime .Seconds % 5 == 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> { </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (r.Next(1, 2) == 1)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (Vector2.Distance(enemy.position, player.position) > 150)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position += enemy.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> soundManager.soundBank.PlayCue("move");</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> else</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position -= enemy.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> soundManager.soundBank.PlayCue("move");</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if( gameTime .TotalGameTime .Milliseconds % 500 == 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> fireAIBullets();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position.X = MathHelper.Clamp(enemy.position.X, enemy.texture.Width / 4, GraphicsDevice.Viewport.Width - enemy.texture.Width / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position.Y = MathHelper.Clamp(enemy.position.Y, enemy.texture.Height / 4, GraphicsDevice.Viewport.Height - enemy.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;">NOW RUN THE GAME! MAKE SURE YOU ADDED ALL THE CODES IN THE RIGHT PLACE AND RIGHT TIME, ELSE YOU WILL GET AN ERROR.</span></div>
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-25133048199038931032013-06-30T14:37:00.002-07:002013-07-02T18:39:36.307-07:00Earn revenue by putting ads in your Website or Blog - Monetization<br />
<br />
Have you ever think of getting paid for your contents and blog posts? If you did, good. If you don't, why not try it ? There are many companies that are letting publishers join their network..<br />
<br />
What is a publisher?<br />
A publisher is someone who makes blog post, articles and websites through the internet. A publisher can pass an application for putting ads in your website, but before they approve it. They have to review the content of your site.<br />
<br />
What do I need to monetize ?<br />
Basically, everyone will tell you that you need a content. The content must be relevant and will have to be categorized easily. Ads are usually connected and have something to do about your content and your website. For example, you post a gadget view about a certain device. The ads in your website will be about gadgets.<br />
<br />
You also need good traffic, which is the number of people who view your website. For 3 days, i got about 500 page views, which I can say is good. I mean my blog is still on progress, I'm still adding contents into this blog. If you post a picture, make sure you also name it properly not just a random name. This will let google crawlers to determine what type of content it is and what is it for.<br />
<br />
If you ever want to try to earn with your contents, try adchoices.<br />
<br />
Need ads on your website? Put adchoices advertisement in your blog and website by clicking the link below. It is pretty easy to get approval,especially when you are referred by someone who is already a publisher<br />
<br />
<br />
<div style="text-align: center;">
<a href="http://www.chitika.com/publishers/apply?refid=kianaudez"><img src="http://images.chitika.net/ref_banners/125x125_money.png" /></a></div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-67100380255477574612013-06-30T13:53:00.003-07:002013-07-02T18:35:30.766-07:00III. Using System input/output to get the files and folders in c#<br />
<br />
Feeling bored and not motivated, i found myself watching my favorite anime "gintama". While watching I decided to code something just for passing time. I decided to write something about paint and files saving. In game development, saving file is important. You need to save scores, screenshots, equipment, game states , settings etc. There are many ways to read files in your computer. So let's start, create a new c# project , yes your right. We're going to use a console c# application..<br />
<br />
Add System.IO in your packages..<br />
using System.IO;<br />
<br />
We can now use I/O packages in our console app..<br />
What we wan't to do is to read a specific filepath / location and show all the files inside it..<br />
Declare 2 arrays that will hold the name of folder and files in a directory.<br />
Directory.Get will do the job for us. All we need to do is to assign the collected data into our string array. After that, use loops to write it in the console.<br />
<br />
<br />
<span style="color: #45818e;">class Program</span><br />
<span style="color: #45818e;">{</span><br />
<span style="color: #45818e;"> static void Main(string[] args)</span><br />
<span style="color: #45818e;"> {</span><br />
<span style="color: #45818e;"> string[] files = Directory.GetFiles(@"C:\");</span><br />
<span style="color: #45818e;"> string[] folders= Directory.GetDirectories(@"c:\");</span><br />
<span style="color: #45818e;"> for (int x = 0; x < folders.Length; x++)</span><br />
<span style="color: #45818e;"> Console.WriteLine(folders[x]);</span><br />
<span style="color: #45818e;"> for (int x = 0; x < files.Length; x++)</span><br />
<span style="color: #45818e;"> Console.WriteLine(files[x]);</span><br />
<span style="color: #45818e;"> Console.ReadKey();</span><br />
<span style="color: #45818e;"> }</span><br />
<span style="color: #45818e;">}</span><br />
<span style="color: #45818e;"><br /></span>
<span style="color: #45818e;">execute the project</span><br />
<span style="color: #45818e;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioK_xqq63fCc2Fuas_QGvSys0VSS66WMLYQmIEmRm1CQr10TQHzsOmRwu1Nr1BFHp2Y4DJYAO5YfUPdFpAIo5QN74zVqGneIxrkbCxqVki8AWnLd3VTpzWAbUdyId0LYO1mlJr2HPD-pM/s754/C%23+Console+Application+-+System.IO+filestreamers.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioK_xqq63fCc2Fuas_QGvSys0VSS66WMLYQmIEmRm1CQr10TQHzsOmRwu1Nr1BFHp2Y4DJYAO5YfUPdFpAIo5QN74zVqGneIxrkbCxqVki8AWnLd3VTpzWAbUdyId0LYO1mlJr2HPD-pM/s320/C%23+Console+Application+-+System.IO+filestreamers.png" width="272" /></a></div>
<span style="color: #45818e;"><br /></span>
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-5804370822129460412013-06-29T16:00:00.000-07:002013-06-30T13:55:17.755-07:00Shingeki no kyoujin Episode 13 :DAfter the long wait, Shigenki no kyoujin episode 13 is now released. Can't wait for the subbed version. Attack on titan episodes are being upload <a href="http://bit.ly/14hGUaq" target="_blank">here</a>, and they have it first.<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.com0tag:blogger.com,1999:blog-2223650567918689977.post-19491608266266317772013-06-29T12:52:00.000-07:002013-07-02T18:37:27.307-07:00II. The camera is your Eyesight 3D XNA<br />
<br />
This is a continuation of the first <a href="http://kianaudez.blogspot.com/2013/06/i-drawing-3d-models-xna.html" target="_blank">topic</a>.<br />
At the first topic, we never used a camera.<br />
We set the mesh view to default.<br />
Let's create a camera that will be able to move freely in the 3D space..<br />
Add the following lines to the top of your class.<br />
<br />
<span style="color: #45818e;"> Matrix viewMatrix=</span><span style="color: #45818e;">Matrix.Identiy</span><span style="color: #45818e;">, rotationMatrix = Matrix.Identiy; </span><span style="color: #6aa84f;">// View matrix is your eyesight in the 3d space, rotation matrix is the rotation of the camera in the value of matrix</span><br />
<span style="color: #45818e;"> Vector3 cameraPosition= Vector3.Zero; //</span><span style="color: #6aa84f;">Camera position set to 0</span><br />
<span style="color: #45818e;">Vector3 cameraOffset = new Vector3(10, 0, -10);</span><span style="color: #6aa84f;"> //Set up a vector3 that will be added to the cameraposition and serves as the camera target</span><br />
<span style="color: #45818e;">Vector3 cameraRotation = Vector3.Zero; </span><span style="color: #6aa84f;">//camera rotation is the rotation of camera in Vector3, we'll update the value of this based on input</span><br />
<span style="color: #45818e;">Vector3 cameraVelocity = Vector3.Zero;</span><span style="color: #6aa84f;"> // The velocity of the camera</span><br />
<span style="color: #45818e;">float movespeed = 5f; </span><span style="color: #6aa84f;">// Movespeed of camera</span><br />
<span style="color: #6aa84f;"><br /></span>
At your update ,set the value of view matrix and a rotation matrix.<br />
<br />
<br />
<span style="color: #45818e;">cameraPosition = Vector3 .Transform (cameraPosition ,rotationMatrix );</span><br />
<span style="color: #6aa84f;">Transform the cameraposition with the rotation of the camera</span><br />
<span style="color: #45818e;"> viewMatrix = Matrix.CreateLookAt(cameraPosition, cameraPosition + cameraOffset, Vector3.Up);</span><br />
<span style="color: #6aa84f;">//set the view matrix, to create a look at we need the camera position, the target, the direction of camera view</span><br />
<span style="color: #6aa84f;"><br /></span>
<span style="color: #6aa84f;"><br /></span>
At your draw method, replace the<br />
<br />
<span style="color: #e06666;">effect.View = Matrix.Identity </span><br />
to<br />
<span style="color: #45818e;"> effect.View = viewMatrix;</span><br />
<br />
With this, the value of house view will be equal to the viewMatrix..<br />
<br />
Next, we need to update the camera..<br />
On your update method, create a set of if statements..<br />
<br />
<div style="text-align: center;">
<span style="color: #cc0000;">[updating in progress]</span></div>
<br />
<br />
<span style="color: #6aa84f;"><br /></span>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-69792932262101673132013-06-29T11:54:00.002-07:002013-07-02T01:40:03.693-07:00I. Drawing 3D models - XNA<title> DRAWING 3D MODELS XNA TUTORIAL </title>
<br />
<div style="text-align: center;">
"Welcome to the 3D world"</div>
<div style="text-align: center;">
<br /></div>
<div style="text-align: left;">
Before we start writing 3d methods, I'm going to explain some basic concepts in 3D space..</div>
<div style="text-align: left;">
When we say 3D, we're talking about x,y,z. A model or game object will have 3d position and 3d rotation. Please see attached image.</div>
<div style="text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_uaLmH1SwnG0FTadJQxG5iGGjyo9c0rFMK4U6LNEzasIEWyVsRlh6Qpha4RLeOKvv0bv1aqjsq5P9BkfG9fMpuminlR1W0-cZflyoN9GsZw-h0SxnuYhwg86u5uKVLbHrjmeqFPyLnAk/s523/add.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="272" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_uaLmH1SwnG0FTadJQxG5iGGjyo9c0rFMK4U6LNEzasIEWyVsRlh6Qpha4RLeOKvv0bv1aqjsq5P9BkfG9fMpuminlR1W0-cZflyoN9GsZw-h0SxnuYhwg86u5uKVLbHrjmeqFPyLnAk/s400/add.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Example, try looking in the image. Move your body to your right, left. Look up, down. Move your head closer to the monitor, farther..</div>
<div class="separator" style="clear: both; text-align: left;">
X = left/ right</div>
<div class="separator" style="clear: both; text-align: left;">
Y = down/ up</div>
<div class="separator" style="clear: both; text-align: left;">
Z = zoom/scale</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div style="text-align: left;">
Let's start making a game using 3 Dimensions. Create a new project, call it <span style="color: #cc0000;">myFirst3dGame</span></div>
<div style="text-align: left;">
Step 1 : Download and importing the Content files.</div>
<a href="https://docs.google.com/file/d/0B_K-acje9NcyOUozanlyeHhnOTQ/edit" target="_blank">house model</a><br />
<br />
Step 2: Creating a class for your gameObject<br />
<br />
On your solutionExplorer (View > Solution Explorer)<br />
Right click Your myFirst3dGame project > Add > new class.. Name it gameObject<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxjwOVpxEsKHCiUh_WcMTKdSy9O5v9UpUiNIbVqLsxX0yO9xXq8Qv_p7Q9kAOmPATA_p1qcjRw0yDiZZiDlXlwMTpRLLdbshP8l_quEZA-jIGE6kQU2nOcLcn4p98iqaWr8aFzgJjKbdM/s523/add.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxjwOVpxEsKHCiUh_WcMTKdSy9O5v9UpUiNIbVqLsxX0yO9xXq8Qv_p7Q9kAOmPATA_p1qcjRw0yDiZZiDlXlwMTpRLLdbshP8l_quEZA-jIGE6kQU2nOcLcn4p98iqaWr8aFzgJjKbdM/s320/add.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[The look of our solution so far]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.Collections.Generic;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.Linq;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.Text;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna .Framework .Graphics ;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">namespace myFirst3dGame</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">{</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> class gameObject</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public Vector3 position = Vector3 .Zero ;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public Vector3 rotation = Vector3.Zero;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public Model model;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public bool alive = true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public Vector3 velocity = Vector3.Zero;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">}</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">As you can see, instead of using vector2, we used vector3 for the position and even the rotation. We need to take the Z axis in our account. Model is the data type of 3D model.</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Now go to your Game1.cs..</span></div>
<div class="separator" style="clear: both;">
Step 3: Declaring your variables.</div>
<div class="separator" style="clear: both;">
At the top of your class, declare:</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">gameObject house;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">Matrix projectionMatrix; //</span><span style="color: #6aa84f;">projection matrix is usually used for camera. Matrix are used for viewing purposes.</span></div>
<div class="separator" style="clear: both;">
Go to your loadcontent and set up the values of variables..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">house = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">house.alive =true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">house.model = Content.Load<model>("house");</model></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians (45f), GraphicsDevice.Viewport.AspectRatio, 1, 700f); </span><span style="color: #6aa84f;">// Create a perspective field of view in Y position, set to 45f degrees and convert to radians.</span></div>
<div class="separator" style="clear: both;">
<span style="color: #6aa84f;">//1 is the near sight position, and 700f farplane</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">house.position.Z = -30;</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPRB5cc5rhnfkVUUmIfO_8DHQjvSdslXsk_O4mMCiMe5v3W48e129iQCr7uQ6n23gD0dYCNlpmb9Xza5X6J66iQlwLRthKjzL7GFAViPQremkx0ykDUWUQIF_G0KOhlQRgY4fbKQrnpuw/s523/add.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="217" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPRB5cc5rhnfkVUUmIfO_8DHQjvSdslXsk_O4mMCiMe5v3W48e129iQCr7uQ6n23gD0dYCNlpmb9Xza5X6J66iQlwLRthKjzL7GFAViPQremkx0ykDUWUQIF_G0KOhlQRgY4fbKQrnpuw/s320/add.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
At your Draw method</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> foreach (ModelMesh mesh in house.model.Meshes)</span><span style="color: #6aa84f; font-size: x-small;"> //for each mesh in house meshes</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> foreach (BasicEffect effect in mesh.Effects) </span><span style="color: #6aa84f; font-size: x-small;">//for each basic effect in house meshes</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> effect.View = Matrix.Identity ; //</span><span style="color: #6aa84f; font-size: x-small;">Set view to default</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> effect.World = Matrix.CreateTranslation(house.position) * Matrix.CreateRotationX(house.rotation.Y); </span><span style="color: #6aa84f; font-size: x-small;">//translate the object to the 3d space</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> effect.EnableDefaultLighting(); </span><span style="color: #6aa84f; font-size: x-small;">//enable default light sources</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> effect.Projection = projectionMatrix; //</span><span style="color: #6aa84f; font-size: x-small;">project the model according to the value of gameobject</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> mesh.Draw(); </span><span style="color: #6aa84f; font-size: x-small;">//draw the mesh</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
RUN THE GAME!!</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKqNIhh5re8stRg3FX8gXrinL9DFDPWWfyvUrFXK_KL5Fqj-9R5NLdLjGlrtIhCPyfltIXOgZvD1HjzbCEGvod7re66Bfx6hd1GJYixbvHfwWG2Or88UyOI7N7_BFmS2y3ryRCYWgPmbQ/s800/add.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKqNIhh5re8stRg3FX8gXrinL9DFDPWWfyvUrFXK_KL5Fqj-9R5NLdLjGlrtIhCPyfltIXOgZvD1HjzbCEGvod7re66Bfx6hd1GJYixbvHfwWG2Or88UyOI7N7_BFmS2y3ryRCYWgPmbQ/s320/add.png" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[Welcome to the 3D World]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
SOURCE CODE</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using System;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using System.Collections.Generic;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using System.Linq;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Audio;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Content;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.GamerServices;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Graphics;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Input;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Media;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">namespace myFirst3dGame</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">{</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> public class Game1 : Microsoft.Xna.Framework.Game</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> GraphicsDeviceManager graphics;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> SpriteBatch spriteBatch;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> gameObject house;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Matrix viewMatrix, projectionMatrix;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Vector3 cameraPosition;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> public Game1()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> graphics = new GraphicsDeviceManager(this);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Content.RootDirectory = "Content";</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> protected override void Initialize()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> // TODO: Add your initialization logic here</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> base.Initialize();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> protected override void LoadContent()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> spriteBatch = new SpriteBatch(GraphicsDevice);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> house = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> house.model = Content.Load<model>("house");</model></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians (45f), GraphicsDevice.Viewport.AspectRatio, 1, 700f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> house.position.Z = -30;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> protected override void UnloadContent()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> protected override void Update(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> base.Update(gameTime);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> protected override void Draw(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> GraphicsDevice.Clear(Color.CornflowerBlue);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> foreach (ModelMesh mesh in house.model.Meshes)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> foreach (BasicEffect effect in mesh.Effects)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> effect.View = Matrix.Identity ;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> effect.World = Matrix.CreateTranslation(house.position) * Matrix.CreateRotationX(house.rotation.Y);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> effect.EnableDefaultLighting();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> effect.Projection = projectionMatrix;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> mesh.Draw();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> base.Draw(gameTime);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">}</span></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Download the source code <a href="https://docs.google.com/file/d/0B_K-acje9NcyY29YMlhvY2N0NDA/edit" target="_blank">here</a>.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-11797314081505169952013-06-29T09:22:00.003-07:002013-07-02T18:44:27.559-07:00II. Reading from a txt file. Lord of strings part II<br />
<br />
As a programmer, you need to learn this too. There are many possible functions for getting data from a txt file. For example , you can use it to read dialogues and draw it in the game screen, reading game settings etc.<br />
<br />
So create a new project and name it whatever you want.<br />
The content we need is a spritefont and a text file. Create a new spritefont and save it as font.<br />
<br />
Copy and paste this to a new textFile, name it <span style="color: #e06666;">anim.txt</span><br />
<br />
<span style="color: #45818e;"><br /></span>
<span style="color: #45818e;">16</span><br />
<span style="color: #45818e;">Year 1982 in Philippines |</span><br />
<span style="color: #45818e;">" " |</span><br />
<span style="color: #45818e;">The Country is currently ruled by the Spanish Empire.|</span><br />
<span style="color: #45818e;">Jose Rizal, a physician, scholar, scientist, and writer founded the La Liga Filipina at Ilaya Street, Tondo Manila in 1982.|</span><br />
<span style="color: #45818e;">La Liga Filipina is a progressive organization ought to build a new group sought |</span><br />
<span style="color: #45818e;">to involve the people directly in the reform movement.|</span><br />
<span style="color: #45818e;">July 6 1982 |</span><br />
<span style="color: #45818e;">Dr. Jose Rizal was arrested and exiled because the La Liga Filipina became a threat to the Spanish Authorities.|</span><br />
<span style="color: #45818e;">During the exile of Dr. Jose Rizal, The organization became inactive and soon to fall.|</span><br />
<span style="color: #45818e;">With the efforts of Domingo Franco and Andres Bonifacio, |</span><br />
<span style="color: #45818e;">the La Liga Filipina was reorganized and decided to support La Solidaridad and the reforms it advocated.|</span><br />
<span style="color: #45818e;">Eventually after some disarray in the leadership of the group, |</span><br />
<span style="color: #45818e;">the Supreme Council of the League dissolved the society.|</span><br />
<span style="color: #45818e;">The Liga membership split into two groups: |</span><br />
<span style="color: #45818e;">the conservatives formed the Cuerpo de Compromisarios which pledged to continue supporting the La Solidaridad while |</span><br />
<span style="color: #45818e;">the radicals led by Bonifacio devoted themselves to a new and secret society, the Katipunan.|</span><br />
<br />
The first line of the text is the number of sentences. Import it to game content and copy the following properties.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgITB1k1lLFrfI0s5rXiWyaTAFzSJuMIgGJsFlM80hU0gPcT7PtXqkUZEtNBWstMFc5BrZojuc86xq9CfhA96ehY6Ozt4otSCe8Ipk5fNkOLeMH9zVZtU8vbgYLss8YHG0s2uD49vKhBMg/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgITB1k1lLFrfI0s5rXiWyaTAFzSJuMIgGJsFlM80hU0gPcT7PtXqkUZEtNBWstMFc5BrZojuc86xq9CfhA96ehY6Ozt4otSCe8Ipk5fNkOLeMH9zVZtU8vbgYLss8YHG0s2uD49vKhBMg/s320/add.jpg" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />
The Using Statements:<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using Microsoft.Xna.Framework;<br />
using Microsoft.Xna.Framework.Audio;<br />
using Microsoft.Xna.Framework.Content;<br />
using Microsoft.Xna.Framework.GamerServices;<br />
using Microsoft.Xna.Framework.Graphics;<br />
using Microsoft.Xna.Framework.Input;<br />
using Microsoft.Xna.Framework.Media;<br />
using System.IO;<br />
<br />
We need to add the System.IO since we are going to use streamreader.<br />
Next : Declaring Variables.<br />
<span style="color: #45818e;"> SpriteFont font; </span><br />
<span style="color: #45818e;"> StreamReader sr; //</span><span style="color: #6aa84f;">Use a member of System.IO, enables us to read the contents of the file</span><br />
<span style="color: #45818e;"> string[] line; </span><span style="color: #6aa84f;">//Array to store the sentences we read</span><br />
<span style="color: #45818e;"> int numberOfLines=0; // </span><span style="color: #6aa84f;">The number of sentences</span><br />
<div>
<br /></div>
<div>
<br /></div>
At your load content method, declare and add the following lines and variables.<br />
<br />
<span style="background-color: #45818e;"><span style="color: #45818e;"><br /></span></span>
<span style="background-color: white; color: #45818e;">string fullPath = "the path of the txt file, see image below";</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWLBjgSi9JB8WuYzXasf-t_YMcwma1UelOqX47q2W5wN5Jao6jiXRz-6rs-HVNFtbuk_rWZ3DL-VHh0K9RssSdIFPHLvMtT3IRF9mKoVpXq7lTI4-nC_p6alQQfahpVHsjn_aDjly9V5k/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWLBjgSi9JB8WuYzXasf-t_YMcwma1UelOqX47q2W5wN5Jao6jiXRz-6rs-HVNFtbuk_rWZ3DL-VHh0K9RssSdIFPHLvMtT3IRF9mKoVpXq7lTI4-nC_p6alQQfahpVHsjn_aDjly9V5k/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #cc0000;">[Copy the full path generated by the game and paste it to the full path. Replace "\" by "/"]</span></div>
<span style="background-color: white; color: #45818e;"><br /></span>
<span style="background-color: white; color: #45818e;">string name ="anim.txt";</span><br />
<span style="color: #45818e;"><br /></span>
<span style="color: #45818e;">sr = new StreamReader(fullPath + name ); //</span><span style="color: #6aa84f;">FIND THE FILE TO READ</span><br />
<span style="color: #45818e;">numberOfLines = Int32.Parse(sr.ReadLine());//<span style="font-size: x-small;"> </span></span><span style="color: #6aa84f; font-size: x-small;">READ THE FIRST LINE TO GET THE No. of sentences</span><br />
<span style="background-color: white; color: #45818e;"></span><br />
<span style="color: #45818e;">line= sr.ReadToEnd().Split('|'); </span><span style="color: #6aa84f;">//read the txt file till the end, seperate each sentences when a '|' character is read.</span><br />
<span style="color: #6aa84f;"><br /></span>
<span style="color: #6aa84f;"><br /></span>
And draw it into the screen, at your draw method..<br />
<span style="color: #45818e;">for (int x = numberOfLines; x > 0; x--) //</span><span style="color: #6aa84f;">set up a loop and read the lines until number of lines to read = 0</span><br />
<span style="color: #45818e;"> {</span><span style="color: #45818e;"> </span><br />
<span style="color: #45818e;"> spriteBatch.DrawString(font, line[x], new Vector2(1, 20 * (x)), Color.White);</span><br />
<span style="color: #45818e;"> } </span><br />
<span style="color: #45818e;"> spriteBatch.End();</span><br />
<br />
<br />
RUN THE PROJECT<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieqZqSBOXVoXtL3xUUgV6Xy6Jywb_QCzokxH4I0bb0lbKkuJ_mqnnOI6pJxHkT41ek615DdwPFLOT1JbI3577wMlH34bBMzCw_tPi4iIAB9cXRm6CvoUI3GugUeblfMOxw6N3BlwHoF6o/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEieqZqSBOXVoXtL3xUUgV6Xy6Jywb_QCzokxH4I0bb0lbKkuJ_mqnnOI6pJxHkT41ek615DdwPFLOT1JbI3577wMlH34bBMzCw_tPi4iIAB9cXRm6CvoUI3GugUeblfMOxw6N3BlwHoF6o/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
SOURCE CODE</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.Collections.Generic;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.Linq;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.Audio;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.Content;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.GamerServices;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.Graphics;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.Input;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using Microsoft.Xna.Framework.Media;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">using System.IO;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">namespace sounds</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">{</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public class Game1 : Microsoft.Xna.Framework.Game</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> GraphicsDeviceManager graphics;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> SpriteBatch spriteBatch;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> SpriteFont font;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> StreamReader sr;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> string[] line;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> int numberOfLines=0;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> public Game1()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> graphics = new GraphicsDeviceManager(this);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> Content.RootDirectory = "Content";</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> protected override void Initialize()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> base.Initialize();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> protected override void LoadContent()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> string fullPath = "D:/sounds/soundsContent/";</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> string name ="anim.txt";</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch = new SpriteBatch(GraphicsDevice);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> sr = new StreamReader(fullPath + name );</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> numberOfLines = Int32.Parse(sr.ReadLine());</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> line= sr.ReadToEnd().Split('|');</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> protected override void UnloadContent()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> protected override void Update(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> base.Update(gameTime);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> protected override void Draw(GameTime gameTime)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> GraphicsDevice.Clear(Color.CornflowerBlue);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Begin();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> for (int x = numberOfLines; x > 0; x--)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch.DrawString(font, line[x], new Vector2(1, 20 * (x)), Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> } </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch.End();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> base.Draw(gameTime);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;">}</span></div>
<div>
<span style="font-size: x-small;"><br /></span></div>
<br />
<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-7686711628102416512013-06-29T08:28:00.000-07:002013-07-02T18:43:54.068-07:00I. Playing with Sounds<br />
<br />
A game without sound effects or background music seems to be boring. Xna framework allows it users to play different sound files. There are several ways to do this, you can use a wave file, mp3 file and even make your own sound library using XACT. Xact is automatically installed into your computer upon installing XNA. To play a mp3/wma sound, you may use this method.<br />
<br />
Create a new project and name it whatever you want..<br />
<br />
Grab a mp3 file on your computer, any song or sound will do.<br />
<br />
The Contents we need:<br />
<br />
A font to show the information about the song and a sound file. To create a SpriteFont click <a href="http://kianaudez.blogspot.com/2013/06/lord-of-strings-string-loading-update.html" target="_blank"><span style="color: #cc0000;">Here.</span></a><span id="goog_295377976"></span><span id="goog_295377977"></span><a href="http://www.blogger.com/"></a><br />
Import it on your game content and declare a new variable for our sound file.<br />
<br />
Song song;<br />
SpriteFont font;<br />
<br />
At your load content, load the content into your value.<br />
<br />
<span style="color: #76a5af;">song = Content.Load<song>("filename of song"); </song></span><span style="color: #93c47d;">//MAKE SURE THE NAME OF THE SOUND IS SAME WITH THE NAME ON THE ASSET PROPERTY</span><br />
<span style="color: #76a5af;">font = Content.Load<spritefont>("name of font");</spritefont></span><br />
finally, play the song..<br />
<br />
<span style="color: #45818e;">MediaPlayer.Play(song);</span><br />
<br />
On your draw method, draw the information.<br />
<br />
<span style="font-size: x-small;"> <span style="color: #3d85c6;"> spriteBatch.Begin();</span></span><br />
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(font, song.Name, Vector2.Zero, Color.Black);</span><br />
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch.End();</span><br />
<br />
Run the game and listen like a boss.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR338Xwvh6rt0xKYH5zBZcMoGCK4-aSEfMe-mocC89HGjecoDCVNH7_L6RSWhZursj_zuvNlmZOeXqiZvHrLyLwppWpMQXuNrN1MdjxDM1nOotixBCC4dTLN24cTuBsQFOme-Fms_Xxek/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhR338Xwvh6rt0xKYH5zBZcMoGCK4-aSEfMe-mocC89HGjecoDCVNH7_L6RSWhZursj_zuvNlmZOeXqiZvHrLyLwppWpMQXuNrN1MdjxDM1nOotixBCC4dTLN24cTuBsQFOme-Fms_Xxek/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
SOURCE CODE</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using System;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using System.Collections.Generic;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using System.Linq;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Audio;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Content;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.GamerServices;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Graphics;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Input;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Media;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">namespace sounds</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">{</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> public class Game1 : Microsoft.Xna.Framework.Game</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> GraphicsDeviceManager graphics;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> SpriteBatch spriteBatch;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> Song song;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> SpriteFont font;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> public Game1()</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> graphics = new GraphicsDeviceManager(this);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> Content.RootDirectory = "Content";</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> protected override void Initialize()</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> base.Initialize();</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> protected override void LoadContent()</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch = new SpriteBatch(GraphicsDevice);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> song = Content.Load<song>("2 The Reluctant Heroes");</song></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> font = Content.Load<spritefont>("font");</spritefont></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> MediaPlayer.Play(song);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> protected override void UnloadContent()</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> protected override void Update(GameTime gameTime)</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> base.Update(gameTime);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> protected override void Draw(GameTime gameTime)</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> GraphicsDevice.Clear(Color.CornflowerBlue);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Begin();</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(font, song.Name, Vector2.Zero, Color.Black);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> spriteBatch.End();</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> base.Draw(gameTime);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #3d85c6; font-size: x-small;">}</span></div>
<div style="text-align: left;">
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comtag:blogger.com,1999:blog-2223650567918689977.post-9573265426206143582013-06-28T15:37:00.001-07:002013-07-02T18:43:20.481-07:00VI. Battle City? Rip off (tank game)<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/0CFTc0MaiG8?feature=player_embedded' frameborder='0'></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
[Watch the project output]</div>
<br />
Lesson VI objectives..<br />
<br />
-Use math related commands,<br />
-Player state management<br />
-Build or Create computer AI<br />
-Importance of Inheritance and OOP<br />
<br />
<span style="color: #45818e;">Create a new project name it tankGame</span><br />
<br />
Project Files:<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5kHh_enzTwNHFxPfK_YfqT02hLhrkNI5F3-rr__vNyQCJ_82QEb-57uj2H49OReLwrfXPcJqLrxhwUo5SBtXyYbEMTfMxHvwGhsT011gvoVtZy9RbRKSzJOB2KHtYJe0S2Mbl1axRLo/s800/background.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf5kHh_enzTwNHFxPfK_YfqT02hLhrkNI5F3-rr__vNyQCJ_82QEb-57uj2H49OReLwrfXPcJqLrxhwUo5SBtXyYbEMTfMxHvwGhsT011gvoVtZy9RbRKSzJOB2KHtYJe0S2Mbl1axRLo/s320/background.jpg" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
[save as background]</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEho4hPYXisOyEqeFdumFO21w6PHHJIxHt9zvOnP_zte3m9S1rT2U_-q9yIyGNugviyONKcaC7I7LGEB8v2wADM_S03pScDHM_LB8LAwBGpryHrNs7ySnDxqsBoErF-1BjUbhA5qSDGk/s280/tank.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUEho4hPYXisOyEqeFdumFO21w6PHHJIxHt9zvOnP_zte3m9S1rT2U_-q9yIyGNugviyONKcaC7I7LGEB8v2wADM_S03pScDHM_LB8LAwBGpryHrNs7ySnDxqsBoErF-1BjUbhA5qSDGk/s280/tank.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
[save as tank]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjldwRLkxUng7-A6TUZi1reeTGHi82aCWIB8l7Plc1CleUo6NPlUmdfBfq1bDHUxX1zONGGqRmfp04AIkSSi1Aot1hdh4PqUpKdGuSz7iyCH25tooCtq59Xva8MChuvCQaqeVp4QZn5-iE/s50/bullet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjldwRLkxUng7-A6TUZi1reeTGHi82aCWIB8l7Plc1CleUo6NPlUmdfBfq1bDHUxX1zONGGqRmfp04AIkSSi1Aot1hdh4PqUpKdGuSz7iyCH25tooCtq59Xva8MChuvCQaqeVp4QZn5-iE/s50/bullet.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[save as bullet]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
First of all, let's create a new class name gameObject. The class will hold a number of variables that will make it easier for us to edit and manipulate it's value..</div>
<div class="separator" style="clear: both; text-align: left;">
To create a new class, see attached image.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ2LS7sB6VtIz_etTtox_0YYb1mc7788Gjrd3S4y1XqBSJgGzuxN2D612UkagPrtEttJMJcA2gs0VC0NISo82p2L3ll9E2yQyPg1zPgirE6eHDrRajNc_bfR-6ygDy9mhzvlDJ77FEy_w/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ2LS7sB6VtIz_etTtox_0YYb1mc7788Gjrd3S4y1XqBSJgGzuxN2D612UkagPrtEttJMJcA2gs0VC0NISo82p2L3ll9E2yQyPg1zPgirE6eHDrRajNc_bfR-6ygDy9mhzvlDJ77FEy_w/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[Figure 1: creating a new class]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Once you created a new class named gameObject, add the following lines at the top of your source code.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Audio;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Content;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.GamerServices;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Graphics;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Input;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">using Microsoft.Xna.Framework.Media;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Now declare the values we need, set it public so we can easily manipulate their values..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> class gameObject</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public Vector2 position = Vector2.Zero;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public float rotation = 0f;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public int numberOfBullets = 5;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public Texture2D texture;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public bool alive = true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public int life =100;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public Vector2 velocity = Vector2.Zero;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both;">
Go to your game.cs source code and create a new instance of gameObject..</div>
<div class="separator" style="clear: both;">
Declare the following variables.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;">gameObject enemy, player;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;">const float moveSpeed = 2f;</span></div>
<span style="color: #76a5af;">const int MaxBullet = 5;</span><br />
At your loadContent, set the gameobject as new gameobject..<br />
<br />
<span style="color: #76a5af;"> player = new gameObject();</span><br />
<span style="color: #76a5af;"> enemy = new gameObject();</span><br />
<span style="color: #76a5af;"> player.texture = Content.Load<texture2d>("tank");</texture2d></span><br />
<span style="color: #76a5af;"> enemy.texture = Content.Load<texture2d>("tank");</texture2d></span><br />
<span style="color: #76a5af;"> enemy.position = new Vector2(400, 100);</span><br />
<span style="color: #45818e;">Vector2 tempposition;</span><br />
<span style="color: #76a5af;"> player.position = new Vector2(100,100);</span><br />
<br />
Declare a variable for the background..<br />
<span style="color: #76a5af;">Texture2D background;</span><br />
<br />
At the load content, set it's value..<br />
<span style="color: #76a5af;">background = Content.Load<texture2d>("background");</texture2d></span><span style="color: #93c47d;"> </span><br />
<span style="color: #93c47d;">// MAKE SURE TO DOWNLOAD AND IMPORT THE TEXTURE IN YOUR GAME CONTENT</span><br />
<span style="color: #93c47d;"><br /></span>
At your draw method, draw the background and the gameObject We need to draw it first so that it is on the lowest layer of drawables..<br />
<br />
<span style="color: #76a5af;"> spriteBatch.Draw(background, Vector2.Zero, Color.White );</span><br />
<span style="color: #76a5af;"> spriteBatch.Draw(enemy.texture, enemy.position, Color.White);</span><br />
<span style="color: #76a5af;"> spriteBatch.Draw(player.texture, player.position, Color.White);</span><br />
<span style="color: #76a5af;"><br /></span>
<span style="color: red;">RUN THE GAME</span><br />
<span style="color: red;"><br /></span>
<span style="color: red;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcI9gD0zYHbJWBukPsNEb5sjEE88krOvng8AuHGPivL0j5KapjyfvfI7wHQVTC7d_wGR5YZ-1d5BoeNucMyZDI3My8gxc5PMlzpjau0fcA6vMlmzQ9r2rwc0RifekWWh29KiIZFOKBT2w/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcI9gD0zYHbJWBukPsNEb5sjEE88krOvng8AuHGPivL0j5KapjyfvfI7wHQVTC7d_wGR5YZ-1d5BoeNucMyZDI3My8gxc5PMlzpjau0fcA6vMlmzQ9r2rwc0RifekWWh29KiIZFOKBT2w/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[SCREENSHOT WILL NOT THE SAME WITH YOUR GAME SINCE I EDITED THE TANK TEXTURE]</div>
<span style="color: red;"><br /></span>
<span style="color: #76a5af;"><br /></span>
After running the game, you'll notice that the texture of the tank are too big for the game screen bounds..<br />
Also, at this lesson we declared a float variable name rotation. We need to update the rotation of the texture depending on the input. To make this possible, we are going to draw the texture in the detailed way..<br />
<br />
<span style="color: #76a5af;"> spriteBatch.Draw(enemy.texture, enemy.position,</span><br />
<span style="color: #76a5af;"> null, Color.White, enemy.rotation,</span><br />
<span style="color: #76a5af;"> new Vector2 (enemy .texture .Width /2, enemy .texture .Height /2),</span><br />
<span style="color: #76a5af;"> 0.5f, SpriteEffects.None, 0);</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqrCOaB1D37JZ1MuNP0U0Eet1oKWMYNrLcY7lIisR11qEj88b1Nk28bXl9MjteGd7Rzi3Xt5xt_368i8MoBPlo1iMfSpfnrQjaTLNiCPaao0SAiZQEH1nDYl_2QQkln4zjuQH9M1yoxT0/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqrCOaB1D37JZ1MuNP0U0Eet1oKWMYNrLcY7lIisR11qEj88b1Nk28bXl9MjteGd7Rzi3Xt5xt_368i8MoBPlo1iMfSpfnrQjaTLNiCPaao0SAiZQEH1nDYl_2QQkln4zjuQH9M1yoxT0/s320/add.jpg" width="320" /></a></div>
<span style="text-align: center;">[SCREENSHOT WILL NOT THE SAME WITH YOUR GAME SINCE I EDITED THE TANK TEXTURE]</span><br />
<br />
To use the 6th usage of spriteBatch.Draw, we need to know the<br />
-Texture<br />
-Positon<br />
-Source Rectangle.. this will draw a specific rectangle in a texture.. in this lesson we'll set it to null so that the entire texture will be drawn..<br />
-Color<br />
-Rotation<br />
-Origin - the middile point of the texture<br />
<div>
-scale</div>
<div>
-SpriteEffect - flip horizontal, vertical..</div>
<div>
-Layer ( back =1 , front = 0)</div>
<div>
<br /></div>
<div>
We set the the scale to 0.5f so it will be resize to size * 0.5</div>
<div>
Run the game..</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6OxIuLFgQiyXRzebwNVQKiMJ8pRDviZwcXwndIRu2sRrWOBoVuyizuql-vfCGM5nPt5KIsvU4yqAmbJF7KwNheNNTdOX_NpANHcMFyVWYDmwSALCeGRVAfI0PcCPrf8EUJtL2KtFp_qc/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6OxIuLFgQiyXRzebwNVQKiMJ8pRDviZwcXwndIRu2sRrWOBoVuyizuql-vfCGM5nPt5KIsvU4yqAmbJF7KwNheNNTdOX_NpANHcMFyVWYDmwSALCeGRVAfI0PcCPrf8EUJtL2KtFp_qc/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[SCREENSHOT WILL NOT THE SAME WITH YOUR GAME SINCE I EDITED THE TANK TEXTURE]</div>
<div>
You'll notice that the texture has been resize into 0.5f scale.. </div>
<div>
Next draw the player tank..</div>
<div>
<span style="color: #76a5af;">if(player.alive){</span></div>
<div>
<div>
<span style="color: #76a5af;">spriteBatch.Draw(player.texture, player.position,</span></div>
<div>
<span style="color: #76a5af;"> null, Color.White, player.rotation,</span></div>
<div>
<span style="color: #76a5af;"> new Vector2(player.texture.Width / 2, player.texture.Height / 2),</span></div>
<div>
<span style="color: #76a5af;"> 0.5f, SpriteEffects.None, 0);</span></div>
</div>
<div>
<span style="color: #76a5af;">}</span><br />
<span style="color: #76a5af;">if (enemy.alive)</span><br />
<span style="color: #76a5af;"> {</span><br />
<span style="color: #76a5af;"> spriteBatch.Draw(enemy.texture, enemy.position,</span><br />
<span style="color: #76a5af;"> null, Color.White, enemy.rotation,</span><br />
<span style="color: #76a5af;"> new Vector2(enemy.texture.Width / 2, enemy.texture.Height / 2),</span><br />
<span style="color: #76a5af;"> 0.5f, SpriteEffects.None, 0);</span><br />
<span style="color: #76a5af;"> }</span></div>
<div>
<br /></div>
<div>
Now, let's declare the input handlers..</div>
<div>
<span style="color: #76a5af;"> KeyboardState currentKeyboardState, oldKeyboardState; // </span><span style="color: #93c47d;">AT THE TOP OF THE CLASS</span></div>
<div>
In the Update Method, configure the input handlers</div>
<div>
<br /></div>
<div>
<div>
<span style="font-size: x-small;"> <span style="color: #76a5af;">currentKeyboardState = Keyboard.GetState();</span></span></div>
<div>
<span style="color: #76a5af; font-size: x-small;">if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> player.rotation += 0.1f;</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div>
<span style="font-size: x-small;"><span style="color: #76a5af;"> </span><span style="color: #76a5af;"> player.rotation -</span><span style="color: #76a5af;">= 0.1f; </span></span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
</div>
<div>
<span style="color: #76a5af; font-size: x-small;">oldKeyboardState = currentKeyboardState;</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div>
<span style="font-size: x-small;">Run the game and press left or right key, you'll notice that our tank is rotating..</span></div>
<div>
<span style="font-size: x-small;">Next the movement..</span></div>
<div>
<span style="font-size: x-small;"><br /></span></div>
<div>
<span style="color: #e06666; font-size: x-small;">NOTE : I EDITED THE TANK TEXTURE, THE OLD TEXTURE IS FACING UP.. I ROTATED IT FACING RIGHT SINCE XNA COORDINATE STARTS AT 3 OCLOCK..</span></div>
<div>
<span style="color: #e06666; font-size: x-small;"><br /></span></div>
<div>
ADD the following lines in your update method after the Keys.Left statement..</div>
<div>
<div>
<span style="font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Up) && oldKeyboardState.IsKeyDown(Keys.Up))</span></div>
<div>
<span style="font-size: x-small;"> {</span></div>
<div>
<span style="font-size: x-small;"> player.position += player.velocity * moveSpeed;</span></div>
<div>
<span style="font-size: x-small;"> }</span></div>
<div>
<span style="font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Down) && oldKeyboardState.IsKeyDown(Keys.Down))</span></div>
<div>
<span style="font-size: x-small;"> {</span></div>
<div>
<span style="font-size: x-small;"> player.position -= player.velocity * moveSpeed;</span></div>
<div>
<span style="font-size: x-small;"> }</span></div>
</div>
<div>
<br /></div>
<div>
If we press up, it will accelerate forward, else backward..</div>
<div>
Then create a new method called updateTank..</div>
<div>
<br /></div>
<div>
<div>
<span style="color: #76a5af;">private void updateTank()</span></div>
<div>
<span style="color: #76a5af;"> {</span></div>
<div>
<span style="color: #76a5af;"> player.velocity.X = (float)Math.Cos(player.rotation ) ;</span></div>
<div>
<span style="color: #76a5af;"> player.velocity.Y = (float)Math.Sin(player.rotation) ;</span></div>
<div>
<span style="color: #76a5af;"> </span></div>
<div>
<span style="color: #76a5af;"> }</span></div>
</div>
<div>
To get the X velocity of an object, get it's Cos Rotation, and for Y sin Rotation..</div>
<div>
The output datatype of Math.Cos and Math.Sin is double, so we need to convert it to float since position needs to be float.. example: 1.5f, 2.01 etc..</div>
<div>
<br /></div>
<div>
At the top of your update method add : </div>
<div>
<span style="color: #76a5af;"> updateTank();</span></div>
<div>
<span style="color: #76a5af;"><br /></span></div>
<div>
RUN THE GAME!!!!</div>
<div>
Make your character Move..</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBKOhhb4qaTSkSEzISd-Pj5_32XWG20mdVptHDlPceM_KZbnBeq5EU69GfQEacs4xBOLu8f1QmWjDa889N33JYVkqwaax4UyMyhtILdxfIojznbwjm3af35nMDj-R1NxjJiIAU4vVN1ZI/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBKOhhb4qaTSkSEzISd-Pj5_32XWG20mdVptHDlPceM_KZbnBeq5EU69GfQEacs4xBOLu8f1QmWjDa889N33JYVkqwaax4UyMyhtILdxfIojznbwjm3af35nMDj-R1NxjJiIAU4vVN1ZI/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
We need to make sure if the player is dead, it can't update its position so wrap the input handlers with a new if statement..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (player.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.rotation += 0.1f;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.rotation -= 0.1f;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Up) && oldKeyboardState.IsKeyDown(Keys.Up))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> tempposition = player.position;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.position += player.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Down) && oldKeyboardState.IsKeyDown(Keys.Down))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.position -= player.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> tempposition = player.position;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">NOW PROJECTILES!!!!!</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Declare the following lines..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> </span><span style="color: #76a5af;">List<gameobject> bullet = new List<gameobject>();</gameobject></gameobject></span></div>
<div class="separator" style="clear: both;">
We want to have a list of bullets since its number may vary..</div>
<div class="separator" style="clear: both;">
Let's create a method for the projectiles, name it updateBullets.</div>
<div class="separator" style="clear: both;">
Also create a method for firing projectiles call it fireBullets..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> private void updateBullets()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> private void fireBullets(</span><span style="color: #76a5af;">)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div>
Now let's add a fire command in the input handler...</div>
<div>
<br /></div>
<div>
<div>
<span style="color: #76a5af; font-size: x-small;">if (currentKeyboardState.IsKeyDown(Keys.Space) && oldKeyboardState.IsKeyUp (Keys.Space))</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> fireBullets();</span></div>
<div>
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
</div>
<div>
Next: Build the events for firing bullets..</div>
<div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> <span style="font-size: x-small;">private void fireBullets()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (player.numberOfBullets > 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> gameObject bulletFire = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.alive = true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.rotation = player.rotation;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.position = new Vector2(player.position.X + bulletFire.velocity.X * 80,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.position.Y + bulletFire.velocity.Y * 80);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bullet.Add(bulletFire);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Then build the events for the updateBullets()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> private void updateBullets()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> foreach (gameObject obj in bullet)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (obj.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> obj.position += obj.velocity * moveSpeed * 2;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Draw(obj.texture, obj.position,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> null, Color.White, obj.rotation,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> new Vector2(obj.texture.Width / 2, obj.texture.Height / 2),</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
</div>
<div>
<br /></div>
<div>
ADD the updateBullets before the spritebatch.end at your draw method.. We are going to put it on draw method because updateBullets contains draws... </div>
<div>
<br /></div>
<div>
<span style="color: #76a5af;">updateBullets(); </span></div>
<div>
<span style="color: #76a5af;"><br /></span></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Run the GAME!!!</div>
<div>
<br /></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDeIAI5kc9XAMbM1mCIQv51dGBY-koLwu_QiX6LIyJJQnsVgicuE8y5idtQ7tS0PcLeQSHKzWBuLJKWt8avE-2ULL6CupBJA-6K5gk7_VRq_9Qu4u-JLL3YMBL_1LV_Oh93qJPfNBhEtM/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDeIAI5kc9XAMbM1mCIQv51dGBY-koLwu_QiX6LIyJJQnsVgicuE8y5idtQ7tS0PcLeQSHKzWBuLJKWt8avE-2ULL6CupBJA-6K5gk7_VRq_9Qu4u-JLL3YMBL_1LV_Oh93qJPfNBhEtM/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[OMG !! WE RELEASED PROJECTILES BUT IT DOESN'T HIT ANYTHING!!]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
THE BULLET SEEMS TO BE UNLIMITED !!</div>
<div class="separator" style="clear: both; text-align: left;">
To fix this, let's edit our fireBullets method..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> <span style="font-size: x-small;">private void fireBullets()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (player.numberOfBullets > 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> gameObject bulletFire = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.alive = true; </span><span style="color: #93c47d; font-size: x-small;">// WE JUST FIRED IT, SO MAKE IT ALIVE !!!</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet"); </texture2d></span><span style="color: #93c47d; font-size: x-small;">// LOAD THE BULLET TEXTURE</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.rotation = player.rotation; </span><span style="color: #93c47d; font-size: x-small;">//THE BULLET ROTATION IS THE SAME WITH THE PLAYER ROTATION</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation); //</span><span style="color: #93c47d; font-size: x-small;">TRIGO</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span><span style="color: #76a5af; font-size: x-small;">//</span><span style="color: #93c47d; font-size: x-small;">TRIGO</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletFire.position = new Vector2(player.position.X + bulletFire.velocity.X * 100,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> player.position.Y + bulletFire.velocity.Y * 100); </span><span style="color: #93c47d; font-size: x-small;">// HERE, WE ADDED THE BULLETVELOCITY * 100 to the player position.. the bullet will come out of the turret.. There are many methods to do this, but i felt lazy so i just copy paste it anyway..</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> </span><span style="color: #76a5af; font-size: x-small;"> bullet.Add(bulletFire); </span><span style="font-size: x-small;"><span style="color: #93c47d;">//ADD THE BULLETFIRE INTO THE LIST OF BULLETS</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> </span><span style="color: #e06666; font-size: x-small;"> </span><span style="font-size: x-small;"><span style="color: #e06666;"> player.numberOfBullets--; </span><span style="color: #93c47d;">//NO MORE CHEATS FOR YOU, subtract 1 bullet every Fire!!</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">OMFG !! MY BULLETS RAN OUT? WHAT SHOULD I DO??</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Create an auto reload method.. Let's call it reloadBullets..</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> void reloadBullets(GameTime gameTime)</span><span style="color: #93c47d;"> // USE THE GAMETIME FOR AUTO RELOAD BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (gameTime.TotalGameTime.Seconds % 5 == 0)</span><span style="color: #93c47d;">//IN EVERY 5 seconds past, reload bullets!!!</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (player .numberOfBullets < MaxBullet )</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> player .numberOfBullets += 1;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (enemy.numberOfBullets < MaxBullet)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> enemy.numberOfBullets++;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both;">
Then at your update method add.. </div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> reloadBullets(gameTime);</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
To check your bullets add this line to your draw method.. Draw it before the spritebatch.End...</div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "BULLETS: " + player.numberOfBullets.ToString(), Vector2.Zero, Color.White);</spritefont></span></div>
<div class="separator" style="clear: both;">
<span style="color: #93c47d;">//I USED A SHORTCUT HERE SINCE I'M TOO LAZY AND SLEEPY TO SHOW EVERY DETAILED AS@RDASFASDJWDASD.. zzzzzzzzzzz</span></div>
<div class="separator" style="clear: both;">
<span style="color: #e06666;">[Font Null?? At your game content > right Click > Add > New Item > click SpriteFont then name it font..]</span></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
RUN THE GAME!!!</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaV9vE3hhFpP0ez_jOfdaiF-yGDB6xG-ZvEbPGtmawLfONn5jzyjEYQ6FdThGXCibiJdG6k2D2opgKGcpSTwR9iAyQ9VxUYbATt1_qHpEkA9kLkxlnP1-kGcGCNpHs6k3lGCDWKDYeDNc/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgaV9vE3hhFpP0ez_jOfdaiF-yGDB6xG-ZvEbPGtmawLfONn5jzyjEYQ6FdThGXCibiJdG6k2D2opgKGcpSTwR9iAyQ9VxUYbATt1_qHpEkA9kLkxlnP1-kGcGCNpHs6k3lGCDWKDYeDNc/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[OMG 5-2 = 3 !! ] </div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
So we have a working method for updating and firing bullets. What we need next is to make a new method that will detect collision between the gameObjects. Let's write the detectCollisions(gameObject gameObject)</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;">private void detectCollisions(gameObject _bullets, gameObject _gameObject){</span></div>
<div class="separator" style="clear: both;">
<span style="color: #93c47d; font-size: x-small;">//_bullets will be from the bulletlist and _gameObject is the player that we want to check the collision with the bullets in the bullet list</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> Vector2 origin, origin1;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> origin = new Vector2(_bullets.texture.Width / 4, _bullets.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> origin1 = new Vector2(_gameObject.texture.Width / 4, _gameObject.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> BoundingBox bulletBounds = new BoundingBox();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> BoundingBox Player = new BoundingBox();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> Player.Min = new Vector3(_gameObject.position.X - origin1 .X ,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _gameObject.position.Y - origin1.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> Player.Max = new Vector3(origin1.X /2+ _gameObject .position .X ,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> origin1.Y + _gameObject.position.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletBounds.Min = new Vector3(_bullets.position.X - origin.X ,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _bullets.position.Y-origin.Y , 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletBounds.Max = new Vector3(origin.X /2 + _bullets.position.X,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> origin.Y + _bullets.position.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (_bullets.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> { if (_gameObject.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (Player.Intersects(bulletBounds))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _bullets.alive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _gameObject.life -= 5;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
In this method, we set the origin to 1/4 of the texture. Why? because we re-sized the texture to 1/2, which means the result origin will be (1/2 )/2 = 1/4.. </div>
<div class="separator" style="clear: both;">
OMG !! WTF is this BoundingBox?? </div>
<div class="separator" style="clear: both;">
BoundingBox are used in collision detections. </div>
<div class="separator" style="clear: both;">
Why did we use Bounding box instead of rectangle? </div>
<div class="separator" style="clear: both;">
We can use rectangle, but since our textures are rotating. It will be a hassle to use it, rectangles are hard to rotate. So let's introduce the boundingBox.. (See attached image for more info)</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOS5fuXW1XGgqmWTWClLw1JOqg3pkLWDGETFLrN_ohJQm30egm3o_w8bqQxFhw7PHivcD7Z6w2LUMSWhPAXl60rLGVraAxbTpcLF60ejAegckCr15p8cFSG_gRc3tPK0qRBMs-6zTqa3s/s828/Bounding+Box+structure+xna+tank.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOS5fuXW1XGgqmWTWClLw1JOqg3pkLWDGETFLrN_ohJQm30egm3o_w8bqQxFhw7PHivcD7Z6w2LUMSWhPAXl60rLGVraAxbTpcLF60ejAegckCr15p8cFSG_gRc3tPK0qRBMs-6zTqa3s/s320/Bounding+Box+structure+xna+tank.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (_bullets.alive) //</span><span style="color: #93c47d; font-size: x-small;">We don't want to have dead bullets killing us.. So if it's alive, check for who will get hit by it</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (Player.Intersects(bulletBounds))</span><span style="color: #93c47d; font-size: x-small;"> // if the bounding box of player intersects with the bounding box of bullet</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _bullets.alive = false; </span><span style="color: #93c47d; font-size: x-small;">// kill bullet first before inflicting the damage,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> _gameObject.life -= 5; </span><span style="color: #93c47d; font-size: x-small;">//inflict the damage</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Let's Add the collision detection to our game..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Go to your updateBullets method, add detect collision(obj(bullet), enemy and another 1 for the player</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> private void updateBullets()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> foreach (gameObject obj in bullet)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (obj.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> obj.position += obj.velocity * moveSpeed * 0.5f;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Draw(obj.texture, obj.position,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> null, Color.White, obj.rotation,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> new Vector2(obj.texture.Width / 2, obj.texture.Height / 2),</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> </span><span style="color: #e06666; font-size: x-small;"> detectCollisions(obj, player); </span></div>
<div class="separator" style="clear: both;">
<span style="color: #e06666; font-size: x-small;"> detectCollisions(obj, enemy);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
We added the following lines in the update bullets since we are updating bullets every one pass of draw method. What's next? Let's check for the life of the game object.. First let's draw the life value of the tanks in our screen so we can see if upon collision, 5 points will be deducted.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
On your draw method, add the following lines before spritebatch.end..</div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;">spriteBatch.DrawString(Content.Load<spritefont>("font"), "LIFE: " + player.life.ToString(),</spritefont></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> new Vector2(player.position.X - player.texture.Width / 2, player.position.Y - player.texture.Height * 0.5f), Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "ENEMY LIFE: " + enemy.life.ToString(),</spritefont></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> new Vector2(GraphicsDevice .Viewport .Width - 200 ,0), Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Then let's make an if statement to check if the hp <= 0..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">On your update method, add the following if statements..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (enemy.life <= 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> enemy.alive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (player.life <= 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> player.alive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Now we can kill the player if it has 0 HP..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">What's next? Restrict the players to go off the game screen bounds..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">At your update method, let's add the clamp..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
</div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">clamp usage = MathHelper.Clamp(value,min,max)</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">For the X position, we want to clamp it to the graphicDevice Viewpoirt.Witdh - origin as it's max, and it's min is the origin of the texture..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">For the Y position, we want to clamp it to the graphicDevice Viewpoirt.Height - origin as it's max, and it's min is the origin of the texture.</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Now the player can't get out of bounds...</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoNDb1u-BJ2vtA5wn3ZZUi28tK3izQqgSWBiuqKoAgb3UdIDK_RJoXLFrHDhh_5Y91sMNXsZAXJ7r-ET9u3YEfIqq_2iMmjpRkvaThflx3Hm8osBlrpubJheN2S1M7X1wAH6h49MLo_NA/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoNDb1u-BJ2vtA5wn3ZZUi28tK3izQqgSWBiuqKoAgb3UdIDK_RJoXLFrHDhh_5Y91sMNXsZAXJ7r-ET9u3YEfIqq_2iMmjpRkvaThflx3Hm8osBlrpubJheN2S1M7X1wAH6h49MLo_NA/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
We're almost done, we only need to set an effect when the bullet hits a player. To do that, download this texture and import to your game..</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgasCkeSCV5UHDHR2oxL1bAykZWQphm6zVK3Be9AecUcjIv6szroADCO2bKdq9MN7vuM4-7DZfacQINjkxcJ5XWGBAKHe1q_qhc1uZ_Zh7gf0ZBfa-eHJDgfJ9YIO24QD6xGA8MgyL_9hs/s256/explosion.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgasCkeSCV5UHDHR2oxL1bAykZWQphm6zVK3Be9AecUcjIv6szroADCO2bKdq9MN7vuM4-7DZfacQINjkxcJ5XWGBAKHe1q_qhc1uZ_Zh7gf0ZBfa-eHJDgfJ9YIO24QD6xGA8MgyL_9hs/s256/explosion.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[save as explosion]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
I'll introduce you to a new method in drawing textures, we're going to use the BlendState.Additive..</div>
<div class="separator" style="clear: both; text-align: left;">
From the word it self, we will blend the texture with another texture. On bulletCollision, we want to draw several explosions with random rotation making it look that it is moving. Let's start doing it's method..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
First declare a list of gameobject for explosion..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
List<gameobject> Explosion = new List<gameobject>();</gameobject></gameobject></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Next : </div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> private void addExplosions(gameObject _bullet)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> gameObject explode = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> explode.alive = true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> explode.position = _bullet.position;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> explode.texture = Content.Load<texture2d>("explosion");</texture2d></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> explode.life = 100;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> </span><span style="color: #e06666;"> Explosion.Add(explode);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
Then add it when a bullet hits someone, at your detectCollision method..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;">if (Player.Intersects(bulletBounds))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> _bullets.alive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> _gameObject.life -= 5;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> </span><span style="color: #e06666;">addExplosions(_bullets);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both;">
Create a method that will draw explosions..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> private void drawExplosion(gameObject explosion)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (explosion.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> for (int x = 0; x <= 15; x++)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> Random r =new Random ();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Draw(explosion.texture, explosion.position,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> null, Color.White, r.Next (1,4),</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> new Vector2(explosion.texture.Width / 2, explosion.texture.Height / 2), 0.5f, SpriteEffects.None, 0);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> explosion.life -=2 ;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (explosion.life <= 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> explosion.alive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.End();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
At the end of your draw method, before the "}".. Draw the explosion.. We don't want to put it inside the exisiting spritebatch process, we created a new spritebatch process with different settings. So it must be after the spriteBatch.End()</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> foreach (gameObject explode in Explosion)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> drawExplosion(explode);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">Run the game!!!</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMos9bVIxLmy1SLBhgufpozNNUCrMuguxcFdbjdkYOFWJoRZjIipzFMtyYjsi3RkQ-pNqRxOAqV9twSMRLtsBR3b-gZuBqEh12s0va4xygEZodAR0Fr764Y5TLbaAicp1WdTDViXPPEVs/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="207" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMos9bVIxLmy1SLBhgufpozNNUCrMuguxcFdbjdkYOFWJoRZjIipzFMtyYjsi3RkQ-pNqRxOAqV9twSMRLtsBR3b-gZuBqEh12s0va4xygEZodAR0Fr764Y5TLbaAicp1WdTDViXPPEVs/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
We don't want to make the 2 tanks collide with each other, so let's create a method that will keep the two tanks apart from each other..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;">private void detectCollisionsAgainstObject(gameObject _gameObject1, gameObject _gameObject)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> //_bullets will be from the bulletlist and _gameObject is the player that we want to check the collision with the bullets in the bullet list</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Vector2 origin, origin1;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> origin = new Vector2(_gameObject1.texture.Width / 4, _gameObject1.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> origin1 = new Vector2(_gameObject.texture.Width / 4, _gameObject.texture.Height / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> BoundingBox bulletBounds = new BoundingBox();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> BoundingBox Player = new BoundingBox();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Player.Min = new Vector3(_gameObject.position.X - origin1.X,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> _gameObject.position.Y - origin1.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> Player.Max = new Vector3(origin1.X / 2 + _gameObject.position.X,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> origin1.Y + _gameObject.position.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> bulletBounds.Min = new Vector3(_gameObject1.position.X - origin.X,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> _gameObject1.position.Y - origin.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> bulletBounds.Max = new Vector3(origin.X / 2 + _gameObject1.position.X,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> origin.Y + _gameObject1.position.Y, 1f);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> if (_gameObject1.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> if (_gameObject.alive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> if (Player.Contains (bulletBounds) != ContainmentType .Disjoint )</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> _gameObject1.position = tempposition;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
And put it on the update method..'</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;">detectCollisionsAgainstObject(player, enemy);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
For the AI method add this line in your update, then write the AI method...</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;">if(enemy.alive) AI(gameTime);</span></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e;"> <span style="font-size: x-small;"> private void AI(GameTime gameTime)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float x = player.position.X - enemy.position.X;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float y = player.position.Y - enemy.position.Y;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> float desiredAngle = (float)Math.Atan2(y, x);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.rotation = desiredAngle;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.velocity.X = (float)Math.Cos(enemy.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.velocity.Y = (float)Math.Sin(enemy.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (gameTime.TotalGameTime .Seconds % 5 == 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> Random r = new Random();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (r.Next(1, 2) == 1)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (Vector2.Distance(enemy.position, player.position) > 300)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position += enemy.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> else</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position -= enemy.velocity * moveSpeed;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position.X = MathHelper.Clamp(enemy.position.X, enemy.texture.Width / 4, GraphicsDevice.Viewport.Width - enemy.texture.Width / 4);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position.Y = MathHelper.Clamp(enemy.position.Y, enemy.texture.Height / 4, GraphicsDevice.Viewport.Height - enemy.texture.Height / 4)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if( gameTime .TotalGameTime .Milliseconds % 500 == 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> fireAIBullets();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-small;">Then create a fireAiBulletMethod..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> <span style="color: #45818e;"> private void fireAIBullets()</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> if (enemy.numberOfBullets > 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> gameObject bulletFire = new gameObject();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.alive = true;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.rotation = enemy.rotation;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bulletFire.position = new Vector2(enemy.position.X + enemy.velocity.X * 100,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.position.Y + bulletFire.velocity.Y * 100);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> bullet.Add(bulletFire);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> enemy.numberOfBullets--;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">We;re almost done, we just need to show a message whenever a player dies..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">In your draw method add a else statement on if (player.alive) and if(enemy.alive)..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> <span style="color: #45818e;"> if (enemy.alive)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(enemy.texture, enemy.position,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> null, Color.White, enemy.rotation,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> new Vector2(enemy.texture.Width / 2, enemy.texture.Height / 2),</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> <span style="color: #cc0000;"> else</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "YOU WIN!: ", new Vector2(GraphicsDevice.Viewport.Width / 2-14, GraphicsDevice.Viewport.Height / 2), Color.Red);</spritefont></span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> <span style="color: #45818e;"> if (player.alive)</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> spriteBatch.Draw(player.texture, player.position,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> null, Color.White, player.rotation,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> new Vector2(player.texture.Width / 2, player.texture.Height / 2), 0.5f, SpriteEffects.None, 0);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> <span style="color: #cc0000;"> else</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "GAME OVER!: ", new Vector2 (GraphicsDevice .Viewport .Width /2 -14, GraphicsDevice .Viewport .Height /2),Color.Red);</spritefont></span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #cc0000; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">RUN THE GAME!!</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaDoDWLudPDoL8GGHYYBP7pxpsVNg0fFu6kUKppDoAVDc64srOSLVCcadYsMwd5lanXhB5__jgpDbq8X7t-K5zm-JkqZMC8RyQsRRo52bdDWHDvYQg2hvk3qbrcx4l3AbwHoTMDU7QlgE/s828/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaDoDWLudPDoL8GGHYYBP7pxpsVNg0fFu6kUKppDoAVDc64srOSLVCcadYsMwd5lanXhB5__jgpDbq8X7t-K5zm-JkqZMC8RyQsRRo52bdDWHDvYQg2hvk3qbrcx4l3AbwHoTMDU7QlgE/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #45818e; font-size: x-small;">Now we're done..</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="color: #45818e; font-size: x-small;">I'll add more explanation next update...</span></div>
<div class="separator" style="clear: both;">
<span style="color: #45818e; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #45818e;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b>THE SOURCE CODE SO FAR!!</b></div>
<div class="separator" style="clear: both; text-align: center;">
<b><br /></b></div>
<div class="separator" style="clear: both; text-align: center;">
<b><br /></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using System;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using System.Collections.Generic;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using System.Linq;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Audio;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Content;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.GamerServices;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Graphics;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Input;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">using Microsoft.Xna.Framework.Media;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">namespace tankGame</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">{</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> public class Game1 : Microsoft.Xna.Framework.Game</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> GraphicsDeviceManager graphics;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> SpriteBatch spriteBatch;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Texture2D background;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> gameObject enemy, player;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> KeyboardState currentKeyboardState, oldKeyboardState;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> const float moveSpeed = 2f;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> const int MaxBullet = 5;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> List<gameobject> bullet = new List<gameobject>();</gameobject></gameobject></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> List<gameobject> Explosion = new List<gameobject>();</gameobject></gameobject></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Vector2 tempposition;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> public Game1()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> graphics = new GraphicsDeviceManager(this);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Content.RootDirectory = "Content";</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> protected override void Initialize()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> base.Initialize();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> protected override void LoadContent()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch = new SpriteBatch(GraphicsDevice);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> background = Content.Load<texture2d>("background");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player = new gameObject();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy = new gameObject();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.texture = Content.Load<texture2d>("tank");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.texture = Content.Load<texture2d>("tank");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position = new Vector2(400, 100);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position = new Vector2(100, 100);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> protected override void UnloadContent()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> protected override void Update(GameTime gameTime)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> currentKeyboardState = Keyboard.GetState();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> updateTank();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> AI(gameTime );</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (player.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> tempposition = player.position;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.rotation += 0.1f;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.rotation -= 0.1f;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Up) && oldKeyboardState.IsKeyDown(Keys.Up))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position += player.velocity * moveSpeed;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Down) && oldKeyboardState.IsKeyDown(Keys.Down))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position-= player.velocity * moveSpeed;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position.X = MathHelper.Clamp(player.position.X, player.texture.Width / 4, GraphicsDevice.Viewport.Width - player.texture.Width / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position.Y = MathHelper.Clamp(player.position.Y, player.texture.Height / 4, GraphicsDevice.Viewport.Height - player.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Space) && oldKeyboardState.IsKeyUp(Keys.Space))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> fireBullets();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (enemy.life <= 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.alive = false;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (player.life <= 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.alive = false;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> detectCollisionsAgainstObject(player, enemy);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> oldKeyboardState = currentKeyboardState;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> reloadBullets(gameTime);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> base.Update(gameTime);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void updateTank()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.velocity.X = (float)Math.Cos(player.rotation ) ;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.velocity.Y = (float)Math.Sin(player.rotation) ;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void updateBullets()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> foreach (gameObject obj in bullet)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (obj.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> obj.position += obj.velocity * moveSpeed * 2f;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Draw(obj.texture, obj.position,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> null, Color.White, obj.rotation,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(obj.texture.Width / 2, obj.texture.Height / 2),</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> detectCollisions(obj, player);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> detectCollisions(obj, enemy);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void fireBullets()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (player.numberOfBullets > 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> gameObject bulletFire = new gameObject();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.alive = true;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.rotation = player.rotation;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.position = new Vector2(player.position.X + bulletFire.velocity.X * 100,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.position.Y + bulletFire.velocity.Y * 100);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bullet.Add(bulletFire);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player.numberOfBullets--;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void fireAIBullets()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (enemy.numberOfBullets > 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> gameObject bulletFire = new gameObject();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.alive = true;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.texture = Content.Load<texture2d>("bullet");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.rotation = enemy.rotation;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.velocity.X = (float)Math.Cos(bulletFire.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.velocity.Y = (float)Math.Sin(bulletFire.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletFire.position = new Vector2(enemy.position.X + enemy.velocity.X * 100,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position.Y + bulletFire.velocity.Y * 100);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bullet.Add(bulletFire);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.numberOfBullets--;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> void reloadBullets(GameTime gameTime)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (gameTime.TotalGameTime.Seconds % 5 == 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (player .numberOfBullets < MaxBullet)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> player .numberOfBullets += 1;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (enemy.numberOfBullets < MaxBullet)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.numberOfBullets++;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> protected override void Draw(GameTime gameTime)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> GraphicsDevice.Clear(Color.CornflowerBlue);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Begin();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Draw(background, Vector2.Zero, Color.White );</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (enemy.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Draw(enemy.texture, enemy.position,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> null, Color.White, enemy.rotation,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(enemy.texture.Width / 2, enemy.texture.Height / 2),</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> 0.5f, SpriteEffects.None, 0);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> else</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "YOU WIN!: ", new Vector2(GraphicsDevice.Viewport.Width / 2-14, GraphicsDevice.Viewport.Height / 2), Color.Red);</spritefont></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (player.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Draw(player.texture, player.position,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> null, Color.White, player.rotation,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(player.texture.Width / 2, player.texture.Height / 2), 0.5f, SpriteEffects.None, 0);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> else</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "GAME OVER!: ", new Vector2 (GraphicsDevice .Viewport .Width /2 -14, GraphicsDevice .Viewport .Height /2),Color.Red);</spritefont></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> updateBullets();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "BULLETS: " + player.numberOfBullets.ToString() + " " + player .rotation .ToString (), Vector2.Zero, Color.White);</spritefont></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "LIFE: " + player.life.ToString(),</spritefont></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(player.position.X - player.texture.Width / 2, player.position.Y - player.texture.Height * 0.5f), Color.White);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.DrawString(Content.Load<spritefont>("font"), "ENEMY LIFE: " + enemy.life.ToString(),</spritefont></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(GraphicsDevice .Viewport .Width - 200 ,0), Color.White);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.End();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> foreach (gameObject explode in Explosion)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> drawExplosion(explode);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> base.Draw(gameTime);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void detectCollisions(gameObject _bullets, gameObject _gameObject){</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Vector2 origin, origin1;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin = new Vector2(_bullets.texture.Width / 4, _bullets.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin1 = new Vector2(_gameObject.texture.Width / 4, _gameObject.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> BoundingBox bulletBounds = new BoundingBox();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> BoundingBox Player = new BoundingBox();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Player.Min = new Vector3(_gameObject.position.X - origin1 .X ,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _gameObject.position.Y - origin1.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Player.Max = new Vector3(origin1.X /2+ _gameObject .position .X ,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin1.Y + _gameObject.position.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletBounds.Min = new Vector3(_bullets.position.X - origin.X ,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _bullets.position.Y-origin.Y , 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletBounds.Max = new Vector3(origin.X /2 + _bullets.position.X,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin.Y + _bullets.position.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (_bullets.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (_gameObject.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (Player.Intersects(bulletBounds))</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _bullets.alive = false;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _gameObject.life -= 5;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> addExplosions(_bullets);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void detectCollisionsAgainstObject(gameObject _gameObject1, gameObject _gameObject)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> //_bullets will be from the bulletlist and _gameObject is the player that we want to check the collision with the bullets in the bullet list</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Vector2 origin, origin1;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin = new Vector2(_gameObject1.texture.Width / 4, _gameObject1.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin1 = new Vector2(_gameObject.texture.Width / 4, _gameObject.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> BoundingBox bulletBounds = new BoundingBox();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> BoundingBox Player = new BoundingBox();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Player.Min = new Vector3(_gameObject.position.X - origin1.X,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _gameObject.position.Y - origin1.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Player.Max = new Vector3(origin1.X / 2 + _gameObject.position.X,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin1.Y + _gameObject.position.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletBounds.Min = new Vector3(_gameObject1.position.X - origin.X,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _gameObject1.position.Y - origin.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> bulletBounds.Max = new Vector3(origin.X / 2 + _gameObject1.position.X,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> origin.Y + _gameObject1.position.Y, 1f);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (_gameObject1.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (_gameObject.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (Player.Contains (bulletBounds) != ContainmentType .Disjoint )</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> _gameObject1.position = tempposition;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> public Texture2D DrawRectangle()</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Color boundsColor;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Texture2D texture = new Texture2D(GraphicsDevice , 1, 1);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> boundsColor = Color.Red;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> texture.SetData<color>(new Color[] { boundsColor });</color></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> return texture;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> public Rectangle createBounds (Vector2 position, int w , int h){</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> int positionx, positiony;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> positionx =(int)position.X -w/4;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> positiony =(int)position.Y - h/4;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> // bounds = new BoundingBox(new Vector3(position.X, position.Y, 1), new Vector3(positionx, positiony, 1));</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> //Matrix rotation = Matrix.CreateRotationZ(MathHelper.ToDegrees (player.rotation));</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> // Vector2 transformedPosition = Vector2.Transform(new Vector2(positionx, positiony), rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> return new Rectangle(positionx , positiony </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> , w / 2</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> , h/2 + (int)Math.Cos (player.rotation * player .position .Y )</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> );</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void drawExplosion(gameObject explosion)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Additive);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (explosion.alive)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> for (int x = 0; x <= 15; x++)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Random r =new Random ();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.Draw(explosion.texture, explosion.position,</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> null, Color.White, r.Next (1,4),</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> new Vector2(explosion.texture.Width / 2, explosion.texture.Height / 2), 0.5f, SpriteEffects.None, 0);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explosion.life -=2 ;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (explosion.life <= 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explosion.alive = false;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> spriteBatch.End();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void addExplosions(gameObject _bullet)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> gameObject explode = new gameObject();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explode.alive = true;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explode.position = _bullet.position;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explode.texture = Content.Load<texture2d>("explosion");</texture2d></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> explode.life = 100;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Explosion.Add(explode);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> private void AI(GameTime gameTime)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> Random r = new Random();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> float x = player.position.X - enemy.position.X;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> float y = player.position.Y - enemy.position.Y;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> float desiredAngle = (float)Math.Atan2(y, x);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.rotation = desiredAngle;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.velocity.X = (float)Math.Cos(enemy.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.velocity.Y = (float)Math.Sin(enemy.rotation);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (gameTime.TotalGameTime .Seconds % 5 == 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> { </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (r.Next(1, 2) == 1)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if (Vector2.Distance(enemy.position, player.position) > 150)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position += enemy.velocity * moveSpeed;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> else</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> {</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position -= enemy.velocity * moveSpeed;</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> if( gameTime .TotalGameTime .Milliseconds % 500 == 0)</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> fireAIBullets();</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> </span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position.X = MathHelper.Clamp(enemy.position.X, enemy.texture.Width / 4, GraphicsDevice.Viewport.Width - enemy.texture.Width / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> enemy.position.Y = MathHelper.Clamp(enemy.position.Y, enemy.texture.Height / 4, GraphicsDevice.Viewport.Height - enemy.texture.Height / 4);</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"><br /></span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;"> }</span></b></div>
<div class="separator" style="clear: both;">
<span style="color: #3d85c6; font-size: x-small;"><b></b></span></div>
<div class="separator" style="clear: both;">
<b><span style="color: #3d85c6; font-size: x-small;">}</span></b></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<br /></div>
<div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.comMetro Manila, Philippines14.595544539181391 120.9800720214843814.472615539181392 120.81871052148438 14.718473539181391 121.14143352148437tag:blogger.com,1999:blog-2223650567918689977.post-34747503995655238512013-06-28T05:41:00.002-07:002013-07-02T18:42:41.355-07:00V. Plane Game?? Shooting Projectiles against enemies<br />
<br />
Create a new project, name it chapter 2.<br />
<br />
Project Files: save and import to game..<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSdOo_Hwqlw07sLZXepB4uZcqc5-O-qoBOmhvFXiZDA0BXGmp7OhgEv5s9fDQDkXK6BHzBmD7ELsb4m_uToL4Cx72aCQsHqi-8N4pD8OBjfrUGjIP-_-msOQ6aZTN5zKF-qXrI4zo9m4/s10/bullet.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvSdOo_Hwqlw07sLZXepB4uZcqc5-O-qoBOmhvFXiZDA0BXGmp7OhgEv5s9fDQDkXK6BHzBmD7ELsb4m_uToL4Cx72aCQsHqi-8N4pD8OBjfrUGjIP-_-msOQ6aZTN5zKF-qXrI4zo9m4/s10/bullet.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[save as bullet]</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu-5Ry_u824X_CClH1xdhyF6AX3LCgcYv5E009PbJuL7tWFPzsBLzSE5VJXDC6DNAVM94o0KsG6ZTKMqsp1fk2LcBQEyF-klZEb6RuhrNr7EGFPvmyVadO5wd5Uv0JonCiNAzcPoztAi0/s100/plane.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu-5Ry_u824X_CClH1xdhyF6AX3LCgcYv5E009PbJuL7tWFPzsBLzSE5VJXDC6DNAVM94o0KsG6ZTKMqsp1fk2LcBQEyF-klZEb6RuhrNr7EGFPvmyVadO5wd5Uv0JonCiNAzcPoztAi0/s100/plane.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[save as plane]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM4o5f24lZoV1fux092B43Qmf2lZhmX5poE4GwH2Yt20OaGIVohsnbVjsW2H65nlVSuf5bivEzgQXLanyymNASE47nyqJQWnbtxWdLSePqtFL-PgrHrkkTKGH2Fa0j8hfztG9hhRxIPso/s100/enemy.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM4o5f24lZoV1fux092B43Qmf2lZhmX5poE4GwH2Yt20OaGIVohsnbVjsW2H65nlVSuf5bivEzgQXLanyymNASE47nyqJQWnbtxWdLSePqtFL-PgrHrkkTKGH2Fa0j8hfztG9hhRxIPso/s100/enemy.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
[save as enemy]</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Before we proceed, let's set up the game..</div>
<div class="separator" style="clear: both; text-align: left;">
let's say the plane can only fire 1 bullet at a time..</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;"> int noOfbullet =1;</span></div>
<div class="separator" style="clear: both; text-align: left;">
Declare the speed,texture,velocity and position variables for the game objects..</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">Texture2D bullet, plane;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">Vector2 bulletPosition, planePosition;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">float bulletSpeed = 5f;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">//Declare Keyboardstates for input handling</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">KeyboardState currentKeyboardState,oldKeyboardState;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;"> bool bulletIsAlive = false;</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">At loadContent</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">bullet = Content.Load<Texture2D>("bullet");</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">plane = Content.Load<Texture2D>("plane");</span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="color: #76a5af;">planePosition = new Vector2(GraphicsDevice.Viewport.Width /2 - plane.Width /2, GraphicsDevice.Viewport.Height - 50- plane.Height);</span></div>
<div class="separator" style="clear: both; text-align: left;">
Set the plane position at the lower middle part of the screen.</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
At the Update Method</div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
set up the input handler</div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-small;"> <span style="color: #76a5af;"> currentKeyboardState = Keyboard.GetState();</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><span style="font-size: x-small;"> </span>planePosition <span style="font-size: x-small;">.X += 10;</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><span style="font-size: x-small;"> </span>planePosition <span style="font-size: x-small;">.X -= 10;</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> oldKeyboardState = currentKeyboardState;</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">At the Draw Method, draw the plane..</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;">spriteBatch.Begin();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;">spriteBatch.Draw(plane,planePosition,Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;">spriteBatch.End();</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">RUN THE GAME</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgezgkrYuSJflT__8r6IlCl3WF5bAtLfrM-U-ECz3pV4G5pmHHDseM7DBCjfQXf8snAmntFPODSBCip6VIZni7k75cNHjHAQgThxxM5j4j639C9xCQWOWtGObPCSrWwEGRQ2v6hJRjq2Fk/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgezgkrYuSJflT__8r6IlCl3WF5bAtLfrM-U-ECz3pV4G5pmHHDseM7DBCjfQXf8snAmntFPODSBCip6VIZni7k75cNHjHAQgThxxM5j4j639C9xCQWOWtGObPCSrWwEGRQ2v6hJRjq2Fk/s320/add.jpg" width="320" /></a></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-size: x-small;">Create a method for bulletUpdate..</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> public void updateBullet()</span></div>
<span style="color: #76a5af;"><br /></span>
<br />
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #93c47d; font-size: x-small;">//IF THE BULLET IS ALIVE UPDATE IT AND DRAW IT</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (bulletIsAlive)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletVelocity = new Vector2(0, bulletSpeed);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletPosition.Y -= bulletVelocity.Y;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Draw(bullet, bulletPosition, Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"> </span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">//<span style="color: #93c47d;">IF THE BULLET IS LESS THAN TO ZERO OR OUT OF BOUNDS KILL THE BULLET SO IT WONT UPDATE</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (bulletPosition.Y < 0)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletIsAlive = false;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> noOfbullet++;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> public void fireBullet()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #93c47d; font-size: x-small;">// IF THE NUMBER OF BULLET IS EQUAL OR GREATER THAN 1 , FIRE THE BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (noOfbullet >= 1)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><span style="color: #76a5af;"> bulletIsAlive = true; </span><span style="color: #93c47d;">//MAKE IT ALIVE SO IT WILL UPDATE</span></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> noOfbullet--;</span><span style="color: #93c47d; font-size: x-small;"> //SUBTRACT THE 1 from the no of Bullet</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> bulletPosition = new Vector2(planePosition.X + plane.Width / 2 - bullet.Width / 2,</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> planePosition.Y); </span><span style="color: #93c47d; font-size: x-small;">//SET THE POSITION OF THE BULLER ON FIRE</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">ADD the updateBullet method in the draw method..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Begin();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.Draw(plane, planePosition, Color.White);</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> updateBullet();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> spriteBatch.End();</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;">ADD the fireBullet to the update method..</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> if (currentKeyboardState.IsKeyDown(Keys.Space) && oldKeyboardState.IsKeyDown(Keys.Space))</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> fireBullet();</span><span style="color: #93c47d; font-size: x-small;"> // IF SPACE IS PRESSED FIRE A BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af; font-size: x-small;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-size: x-small;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPw9GakQfGghFQNVoOugA6PquADqquEilPoMnLfsP9n2j-68pRK6KiAPQJ-jjrMmbn-9-fBrAEq4D9xbxxyATHSc5yjiGkKQscxU8FwyWvizg98mTnCXSVCHWcsprrEe0yXjaKlY3x-oM/s797/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="191" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPw9GakQfGghFQNVoOugA6PquADqquEilPoMnLfsP9n2j-68pRK6KiAPQJ-jjrMmbn-9-fBrAEq4D9xbxxyATHSc5yjiGkKQscxU8FwyWvizg98mTnCXSVCHWcsprrEe0yXjaKlY3x-oM/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
[RUN THE GAME AND FIRE A BULLET]</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Now we're going to set up the enemy..</div>
<div class="separator" style="clear: both;">
At the bottom of your public Game1 class, create a new class.</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> class enemy{</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public Vector2 position;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public bool alive;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public Texture2D texture;</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> public enemy()</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;">}</span></div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
This will hold the values of enemies..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
Then after your game1 class, where you declare variables. Declare a new list of enemies and the enemy number..</div>
<div class="separator" style="clear: both;">
<br /></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> List<enemy> enemyList = new List<enemy>();</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> const int enemyNumber = 5;</span></div>
<div>
<br />
<br />
At your load content , set up the enemy and add it to the enemy list depending on its number..<br />
<br />
for (int x = 0; x <= enemyNumber; x++)<br />
{<br />
int y = 0; <span style="color: #93c47d;">//set the y position</span><br />
enemy n = new enemy(); <span style="color: #93c47d;">//create a new enemy</span><br />
n.texture = Content.Load<Texture2D>("enemy"); <span style="color: #93c47d;">// set the current texture of enemy</span><br />
n.alive = true;<span style="color: #93c47d;"> //set the enemy alive </span><br />
n.position = new Vector2(x* 120 , y);<span style="color: #93c47d;"> //set the position of the enemy</span><br />
enemyList.Add(n); <span style="color: #93c47d;">//add the new enemy to the list of enemies</span><br />
}<br />
<br />
On your Draw Method...<br />
Add the following lines..<br />
<br />
<span style="color: #76a5af;"> foreach (enemy enemy in enemyList)</span> <span style="color: #93c47d;">//FOREACH ENEMY IN THE ENEMELIST</span><br />
<span style="color: #76a5af;"> {</span><br />
<span style="color: #76a5af;"> if (enemy.alive)</span> <span style="color: #93c47d;">//IF THE ENEMY IS ALIVE DRAW IT</span><br />
<span style="color: #76a5af;"> {</span><br />
<span style="color: #76a5af;"> spriteBatch.Draw(enemy.texture, enemy.position, Color.White);</span><br />
<span style="color: #76a5af;"> }</span><br />
<span style="color: #76a5af;">}</span><br />
<br />
<div style="text-align: center;">
[NOW RUN THE GAME]</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2X2Q1vTvmSv4wG9oMyPGTZv8zBOYDZxoRZx9PJdu6gbcqeIUhw_xDJyI-Fje3FmDd3vEUIX2VVtJQD-7tjzvkSxYv9DRRfjZyvaFjFozdfpnixQh8MOcARaaHV0_kqieW_26im1ySMTI/s1366/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2X2Q1vTvmSv4wG9oMyPGTZv8zBOYDZxoRZx9PJdu6gbcqeIUhw_xDJyI-Fje3FmDd3vEUIX2VVtJQD-7tjzvkSxYv9DRRfjZyvaFjFozdfpnixQh8MOcARaaHV0_kqieW_26im1ySMTI/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
Next create a collision detection...</div>
<div class="separator" style="clear: both; text-align: left;">
The method will check 1 enemy..</div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;">private void updateEnemies(enemy enemy)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (enemy.alive)</span><span style="color: #93c47d; font-size: x-small;"> //IF THE ENEMY IS ALIVE CHECK THE POSITION OF BULLET AND ENEMY</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> if (bulletPosition.X >= enemy.position.X</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> && bulletPosition.X <= enemy.position.X + enemy.texture.Width</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> && bulletPosition .Y > enemy .position .Y</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> && bulletPosition.Y < enemy.position.Y + enemy.texture.Height)</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> </span><span style="color: #93c47d;"> //CHECK THE BOUNDS OF ENEMY AND BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> {</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> enemy.alive = false; </span><span style="color: #93c47d;">//IF THE BULLET HITS THE ENEMY KILL ENEMY</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> bulletIsAlive = false; </span><span style="color: #93c47d;">//KILL THE BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> noOfbullet++;</span><span style="color: #93c47d;"> //ADD 1 BULLET</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
<div class="separator" style="clear: both;">
<span style="color: #76a5af;"> }</span></div>
Now we have the updateEnemies method, we need to place a foreach loop in the Update method that will loop all the enemies in the enemylist and update it by using updateEnemies<br />
<br />
<span style="color: #76a5af;">foreach (enemy enemy in enemyList)</span><br />
<span style="color: #76a5af;"> {</span><br />
<span style="color: #76a5af;"> updateEnemies(enemy); </span><span style="color: #93c47d;">//pass the enemy into the updateEnemy Method</span><br />
<span style="color: #76a5af;"> }</span><br />
<span style="color: #76a5af;"><br /></span>
We're almost done, feel free to edit the source code whatever event you want to take place at the end of the game..<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif10s1a-m6Wp_pEkVSyiGbgtNd4lGI3L999pBFYnu19h08HnYJVpqf2tDWd_jgA03AHbS3WWQplG7VT6ekDpKKJNhr6lDldAEAFav1LtON9xqpSCiv8dPY3x9Bq_0CEMlJ4x7cWcs0HjM/s831/add.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="199" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEif10s1a-m6Wp_pEkVSyiGbgtNd4lGI3L999pBFYnu19h08HnYJVpqf2tDWd_jgA03AHbS3WWQplG7VT6ekDpKKJNhr6lDldAEAFav1LtON9xqpSCiv8dPY3x9Bq_0CEMlJ4x7cWcs0HjM/s320/add.jpg" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;">[</span><span style="color: #e06666; text-align: start;">Challenge : create a method that will update the position or behavior of the enemies.</span><span style="text-align: start;">.]</span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><b>SOURCE CODE</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using System;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using System.Collections.Generic;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using System.Linq;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.Audio;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.Content;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.GamerServices;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.Graphics;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.Input;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>using Microsoft.Xna.Framework.Media;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>namespace chapter2</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>{</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public class Game1 : Microsoft.Xna.Framework.Game</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> GraphicsDeviceManager graphics;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> SpriteBatch spriteBatch;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> Texture2D bullet, plane;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> Vector2 bulletPosition, planePosition;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> float bulletSpeed = 5f;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> int noOfbullet = 1;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> KeyboardState currentKeyboardState, oldKeyboardState;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bool bulletIsAlive = false;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> Vector2 bulletVelocity = Vector2.Zero;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> List<enemy> enemyList = new List<enemy>();</enemy></enemy></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> const int enemyNumber = 5;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public Game1()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> graphics = new GraphicsDeviceManager(this);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> Content.RootDirectory = "Content";</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> protected override void Initialize()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> base.Initialize();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> protected override void LoadContent()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch = new SpriteBatch(GraphicsDevice);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bullet = Content.Load<texture2d>("bullet");</texture2d></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> plane = Content.Load<texture2d>("plane");</texture2d></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> planePosition = new Vector2(GraphicsDevice.Viewport.Width / 2 - plane.Width / 2, GraphicsDevice.Viewport.Height - 50 -plane.Height);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> for (int x = 0; x <= enemyNumber; x++)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> int y = 0;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> enemy n = new enemy();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> n.texture = Content.Load<texture2d>("enemy");</texture2d></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> n.alive = true;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> n.position = new Vector2(x* 120 , y);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> enemyList.Add(n);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> protected override void UnloadContent()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> protected override void Update(GameTime gameTime)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> currentKeyboardState = Keyboard.GetState();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (currentKeyboardState.IsKeyDown(Keys.Right) && oldKeyboardState.IsKeyDown(Keys.Right))</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> planePosition.X += 10;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (currentKeyboardState.IsKeyDown(Keys.Left) && oldKeyboardState.IsKeyDown(Keys.Left))</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> planePosition.X -= 10;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (currentKeyboardState.IsKeyDown(Keys.Space) && oldKeyboardState.IsKeyDown(Keys.Space))</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> fireBullet();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> foreach (enemy enemy in enemyList)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> updateEnemies(enemy);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> oldKeyboardState = currentKeyboardState;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> base.Update(gameTime);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public void updateBullet()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (bulletIsAlive)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletVelocity = new Vector2(0, bulletSpeed);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletPosition.Y -= bulletVelocity.Y;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch.Draw(bullet, bulletPosition, Color.White);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (bulletPosition.Y < 0)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletIsAlive = false;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> noOfbullet++;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public void fireBullet()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (noOfbullet >= 1)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletIsAlive = true;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> noOfbullet--;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletPosition = new Vector2(planePosition.X + plane.Width / 2 - bullet.Width / 2,</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> planePosition.Y);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> private void updateEnemies(enemy enemy)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (enemy.alive)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (bulletPosition.X >= enemy.position.X</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> && bulletPosition.X <= enemy.position.X + enemy.texture.Width</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> && bulletPosition .Y > enemy .position .Y</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> && bulletPosition.Y < enemy.position.Y + enemy.texture.Height)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> enemy.alive = false;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> bulletIsAlive = false;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> noOfbullet++;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> protected override void Draw(GameTime gameTime)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> GraphicsDevice.Clear(Color.CornflowerBlue);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch.Begin();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch.Draw(plane, planePosition, Color.White);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> foreach (enemy enemy in enemyList)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> if (enemy.alive)</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> {</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch.Draw(enemy.texture, enemy.position, Color.White);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> updateBullet();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> spriteBatch.End();</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> base.Draw(gameTime);</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> class enemy{</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public Vector2 position;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public bool alive;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public Texture2D texture;</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> public enemy()</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> { </b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b> }</b></span></div>
<div class="separator" style="clear: both;">
<span style="color: #0b5394; font-size: x-small;"><b>}</b></span></div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="text-align: start;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
<br />
<br />
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br /><div class="blogger-post-footer">-Kianaudez-</div>Anonymoushttp://www.blogger.com/profile/05409454787236749516noreply@blogger.com