<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Problem with collision in text game</title>
		<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game</link>
		<description>Posts in the discussion thread &quot;Problem with collision in text game&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Tue, 17 Mar 2026 03:09:58 +0000</lastBuildDate>
		
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62971</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62971</link>
				<description></description>
				<pubDate>Tue, 30 Oct 2007 02:58:19 +0000</pubDate>
				<wikidot:authorName>webfaction</wikidot:authorName>				<wikidot:authorUserId>41828</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Yes it does alot, thanks.</p> <p>u9 you seriously rock :)</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62898</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62898</link>
				<description></description>
				<pubDate>Mon, 29 Oct 2007 21:57:26 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Variables inside functions usually only exist inside those functions (except those you define with <tt>Global</tt>. They do not even contain the same value every time you call the function. So in theory, a bullet created inside a function would disappear when the function ends, if you don't return the bullet to the caller (the place where you called the function). However, in Blitz, it seems that you can always get to all objects created of any type using the For-Each loop, and that is why you have access to all bullets from different functions. This is the reason this works. If this wasn't the case, you would need to keep track of the bullets yourself. You do not move the entire TYPE bullet. For-Each loops through all instances created of a particular type.</p> <p>hope it helps<br /> u9</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62886</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62886</link>
				<description></description>
				<pubDate>Mon, 29 Oct 2007 21:12:21 +0000</pubDate>
				<wikidot:authorName>webfaction</wikidot:authorName>				<wikidot:authorUserId>41828</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Thanks alot that really helped. However there are a few things that i just don't understand and i have been reading over this all day.Inregards to making seperate functions to handle the different aspects of the bullets.My understanding is that If a bullet is made in one function than in is local and kept to that function. However the example you provided(Which works nicely) has the bullet being created and moved in seperate functions without using the bullets variable name in more than one function. The only thing i can think of is that when you are for example moving the bullet you arent moving the object &quot;Newbullet&quot; but that you are moving the entire TYPE bullet. Is this right i am really confused?</p> <p>Thanks alot</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62369</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62369</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 20:13:06 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Here's one way of making it into functions. The main purpose of functions is for code you call repeatedly (and from different locations). E.g. a very good example of a function is <tt>KeyDown()</tt>. This function takes as an input the number of the key you wish to test for a key-press, and returns <tt>true</tt> or <tt>false</tt> depending on whether the key was pressed or not. <tt>KeyDown()</tt> is a built-in function, but you can also define your own functions that you may need, and give them the input that they need to operate on. Here's an example of a function:</p> <div class="code"> <pre><code>Function add( a, b ) Return a + b End Function</code></pre></div> <p>Granted, this function is a little redundant since you already have a + you can use :) , but it is just to give you an idea of how to use functions. If the function does not return anything, but only as side-effects, it is usually called a procedure. Example of such is the <tt>Text</tt> procedure you use to display the plane and bullets with. It returns nothing, but instead makes text appear on the screen.</p> <p>I do not recommend you use gotos, as it encourages bad programming habits.</p> <p>Hope this helps&#8230;</p> <p>P.s. Note, you write like so when you want to post code:</p> <p><span style="white-space: pre-wrap;">[[code]]</span><br /> code here<br /> <span style="white-space: pre-wrap;">[[/code]]</span></p> <p>and the code will look as i have posted below. Optionally you can just mark your code when you have pasted in the editor, and click the <tt>i++</tt> icon of the text editor. This will wrap the marked text inside code tags.</p> <div class="code"> <pre><code>;Creates variables to represent screenwidth and screenheight Global sh=480 Global sw=640 ;Sets Graphics Mode Graphics sw,sh,0,0 ;Sets the buffer that we are currently writing on to be the &quot;BackBuffer&quot; SetBuffer BackBuffer() ;Create Types Type obj Field x,y,i$,h,f,w,hi End Type Type bullet Field x,y,i$,h,f End Type Type enemy Field x,y,i$,h,w,hi End Type ;Create Player Global player.obj = New obj player\x=100 player\y=100 player\i$=&quot;}&quot; player\h=0 player\w=10 player\hi=15 ; Function to draw everything Function draw() ; Draw player Text player\x,player\y,player\i$ ; Draw bullets For curBullet.bullet = Each bullet Text curBullet\x, curBullet\y, curBullet\i$ Next ; Draw enemies For curEnemy.enemy = Each enemy ; Put drawing stuff for enemy here Next End Function ; Borders for plane Function border() If player\x&gt;= sw-player\w Then player\x=sw-player\w If player\x=&lt;0 Then player\x=0 If player\y&gt;=sh-player\hi Then player\y=sh-player\hi If player\y=&lt;0 Then player\y=0 End Function ;Creates HUD Function HUD() Text 0,0,&quot;X Position:&quot;+player\x Text 0,10,&quot;Y Position:&quot;+player\y End Function Function CreateBullet() newBullet.bullet = New bullet newBullet\x = player\x newBullet\y = player\y newBullet\i$ = &quot;.&quot; newBullet\h = 0 newBullet\f = 1 End Function Function MoveBullets() For curBullet.bullet = Each bullet curBullet\x = curBullet\x + 5 Text curBullet\x, curBullet\y, curBullet\i$ Next End Function Function CheckCollisions() For curBullet.bullet = Each bullet ; Delete bullet if it has passed screen If curBullet\x &gt; sw Then Delete curBullet Else For curEnemy.enemy = Each enemy ; Check if enemy and bullet collide, if so delete both Next End If Next End Function ;Main Game Loop While KeyDown(1)=0 Cls ;Scan for input If KeyDown(200) Then player\y = player\y - 2 If KeyDown(208) Then player\y = player\y + 2 If KeyDown(203) Then player\x = player\x - 2 ;player\i$=&quot;{&quot; If KeyDown(205) Then player\x = player\x + 2 ;player\i$=&quot;}&quot; ;If Spacebar is pressed then fire a bullet If KeyHit(57) Then CreateBullet() ;Goes through each bullet and moves it forward by 5 pixels MoveBullets CheckCollisions HUD border draw ;Flips everything from the backbuffer to the front buffer Flip Wend</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62338</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62338</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 18:00:28 +0000</pubDate>
				<wikidot:authorName>webfaction</wikidot:authorName>				<wikidot:authorUserId>41828</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Success! Thanks Link it worked perfectly.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62336</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62336</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 17:58:29 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Thanks Link i am going to try that in a just a min. U9 here is my code. i keep trying to get it orderly but when i post the code its format becomes alittle unruly. I was trying to get the code to work in functions but because i was creating a bullet inside a function it could only be a local variable so i couldn't access it in the other functions. I was considering placing the code to create a bullet somewhere in the program as a global variable and use a goto statement to go there once the fire key was pressed. anyways this is what i ended up with with when i decided to keep it all in the main loop.<br /> &lt;<span style="text-decoration: line-through;">code</span>&gt;<span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span>&#8212;<br /> ;Sets Graphics Mode<br /> Graphics 640,480,0,0</p> <p>;Sets the buffer that we are currently writing on to be the &quot;BackBuffer&quot;<br /> SetBuffer BackBuffer()</p> <p>;Creates variables to represent screenwidth and screenheight<br /> Global sh=480<br /> Global sw=640<br /> ;Create Type</p> <p>Type obj<br /> Field x,y,i$,h,f,w,hi<br /> End Type</p> <p>Type bullet<br /> Field x,y,i$,h,f<br /> End Type</p> <p>Type enemy<br /> Field x,y,i$,h,w,hi<br /> End Type</p> <p>;Create Player<br /> Global player.obj = New obj<br /> player\x=100<br /> player\y=100<br /> player\i$=&quot;}&quot;<br /> player\h=0<br /> player\w=10<br /> player\hi=15</p> <p>;Create Function to draw game<br /> Function draw()<br /> Text player\x,player\y,player\i$<br /> End Function</p> <p>;Create Borders for plane<br /> Function border()</p> <p>If player\x&gt;= sw-player\w Then player\x=sw-player\w<br /> If player\x=&lt;0 Then player\x=0<br /> If player\y&gt;=sh-player\hi Then player\y=sh-player\hi<br /> If player\y=&lt;0 Then player\y=0<br /> End Function</p> <p>;Creates HUD</p> <p>Function HUD()</p> <p>Text 0,0,&quot;X Position:&quot;+player\x<br /> Text 0,10,&quot;Y Position:&quot;+player\y</p> <p>End Function</p> <p>;Main Game Loop<br /> While KeyDown(1)=0<br /> Cls<br /> ;Scan for input</p> <p>If KeyDown(200) Then player\y=player\y-2<br /> If KeyDown(208) Then player\y=player\y+2<br /> If KeyDown(203) Then player\x=player\x-2 ;player\i$=&quot;{&quot;<br /> If KeyDown(205) Then player\x=player\x+2 player\i$=&quot;}&quot;<br /> ;If Spacebar is pressed then create a bullet<br /> If KeyHit(57) Then<br /> bullet.bullet= New bullet<br /> bullet\x=player\x<br /> bullet\y=player\y<br /> bullet\i$=&quot;.&quot;<br /> bullet\h=0<br /> bullet\f=1<br /> End If</p> <p>;Goes through each bullet and moves it forward by 5 pixels,Draws it to screen,Deletes bullets that are now offscreen<br /> For bullet.bullet= Each bullet<br /> bullet\x=bullet\x+5<br /> Text bullet\x,bullet\y,bullet\i$<br /> If bullet\x&gt;sw Then Delete bullet<br /> Next</p> <p>;Calls Functions<br /> HUD<br /> border<br /> draw</p> <p>;Flips everything from the backbuffer to the front buffer<br /> Flip<br /> ;Ends the loop<br /> Wend<br /> &lt;<span style="text-decoration: line-through;">end code</span>&gt;<span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span><span style="text-decoration: line-through;">-</span></p> <p>Thanks for the help</p> <p>-Webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62257</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62257</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 09:11:43 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Well&#8230; <a href="http://www.amazon.com/Code-Complete-Second-Steve-McConnell/dp/0735619670/ref=pd_bbs_sr_1/002-1960123-4394412?ie=UTF8&amp;s=books&amp;qid=1193476188&amp;sr=1-1">good programming practice</a> dictate your functions (including your main) should not fill more then a screen, so you can have it all visible at one time ;)</p> <p>Anyway, if you post the code i can show you how to make it into a function.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62245</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62245</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 05:26:36 +0000</pubDate>
				<wikidot:authorName>Linkage2</wikidot:authorName>				<wikidot:authorUserId>29081</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Ah, that happens to me too. I'm guessing you click on the login and then it just stays there. When that happens, try waiting a few seconds, then click on &quot;No account yet?&quot;. Then, when it goes to the create-an-account view, click on Cancel and Refresh the page. You &quot;should&quot; be logged in then.</p> <p>I can't guarantee it'll work, but it works for me.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62243</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62243</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 04:43:59 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Thanks Link, I really wasn't sure about that. It was always stressed by my teacher to put as many things as possible into functions or sub routines.</p> <p>And when I try to log in nothing happens, the logging in bar just keeps doing its thing and then nothing happens and i have to close out the window. I tried the different check box variations and nothing seems to work.</p> <p>-Webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62220</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62220</link>
				<description></description>
				<pubDate>Sat, 27 Oct 2007 00:41:27 +0000</pubDate>
				<wikidot:authorName>Linkage2</wikidot:authorName>				<wikidot:authorUserId>29081</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Well, the way I see it there's nothing wrong with having even all of your code inside one main game loop. I myself usually have about 70-80ish% of my code inside the main loop and only really create a function/sub for things that I think I'll find myself calling multiple times in the loop.</p> <p>By the way, what's the problem when you try to log in? What happens?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-62166</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-62166</link>
				<description></description>
				<pubDate>Fri, 26 Oct 2007 20:28:49 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Alright so i got the bullets firing and all but i was unable to do it using functions. The only way i could get it to work was by putting most of the code inside the main game loop. Is this ok?</p> <p>-Webfaction</p> <p>ps: I still can't log in with my username should i try making a new one since its been almost 3 weeks?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60924</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60924</link>
				<description></description>
				<pubDate>Mon, 22 Oct 2007 21:04:44 +0000</pubDate>
				<wikidot:authorName>hartnell</wikidot:authorName>				<wikidot:authorUserId>10978</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <img src="http://www.wikidot.com/common--images/avatars/10/10978/a48.png" alt="a48.png" class="image" /> <p>Hartnell say : u9 rock.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60885</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60885</link>
				<description></description>
				<pubDate>Mon, 22 Oct 2007 19:50:18 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Thanks u9. You're quite the helpful guy around here. I am going to give it another shot after i get home from work tonight. I appreciate all the time you seem to be taking, it's very kind of you.</p> <p>-Webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60809</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60809</link>
				<description></description>
				<pubDate>Mon, 22 Oct 2007 16:09:37 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi webfaction,</p> <p>Please remember to put source code you post inside <span style="white-space: pre-wrap;">[[code]]</span> and <span style="white-space: pre-wrap;">[[/code]]</span> tags, so it becomes easier to read.</p> <p>I only posted a solution to the <tt>bullet()</tt> function so that you would see why it didn't execute. The function is fundamentally flawed. It does too many things. What you need is to make the following functions (among others):</p> <ul> <li><tt>CreateBullet()</tt></li> <li><tt>MoveAllBullets()</tt></li> <li><tt>CheckCollisionBulletEnemy()</tt></li> </ul> <p>These are the functions you need to make. The function <tt>CreateBullet()</tt> should <strong>only</strong> creates a bullet and should <strong>only</strong> be called when the player presses fire (This btw, makes your <tt>bullet\f</tt> parameter redundant as all existing bullets have in fact been fired :) ). You should check if the player presses fire in the main loop.</p> <p>The function <tt>MoveAllBullets()</tt> should <strong>only</strong> move all existing bullets, and finally, <tt>CheckCollisionBulletEnemy()</tt> should have the task of looping through all bullets and enemies and seeing if any of them collide. If any collide, then the function should delete the appropriate bullet and enemy.</p> <p>At least try and create the first two functions first and tell me how it goes. The second function simply loops through all the bullets and moves them. Very basic function.</p> <p>Actually all three functions i mentioned above are in fact included in your current <tt>bullet()</tt> function, and that is actually what is wrong with it.</p> <p>About the code above. I haven't tried it, but i think this line is the fault:</p> <div class="code"> <pre><code>If liveRounds\x &gt; enemy\x Then Delete enemy liveRounds\h=1 ; I changed this to add the flag H</code></pre></div> <p>You probably cannot do two things at the same time, i.e. deleting enemy and setting <tt>liveRounds\h</tt> to 1. You need to do it on separate lines like so:</p> <div class="code"> <pre><code>If liveRounds\x &gt; enemy\x Then Delete enemy liveRounds\h=1 End If</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60747</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60747</link>
				<description></description>
				<pubDate>Mon, 22 Oct 2007 12:42:29 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Hey u9,</p> <p>So i went through what you said and i made some progress but i am still having some trouble.</p> <p>I am having trouble making a function that can check for collisions i think because the variables aren't global so they don't exist at the time. I tried adding the collision into the &quot;function bullet&quot; that you had outlined before but it didn't work out so well. I am assuming it is another error in my logic but i just can't place my finger on it.</p> <div class="content-separator" style="display: none:"></div> <p>Function bullet()<br /> liveRounds.bullet = New bullet<br /> liveRounds\x = 0<br /> liveRounds\y = shipy<br /> liveRounds\i$ = &quot;.&quot;<br /> liveRounds\h = 0<br /> liveRounds\s = 5<br /> liveRounds\f = 0</p> <p>If KeyHit(57) Then liveRounds\f = 1</p> <p>For liveRounds.bullet = Each bullet<br /> If liveRounds\f = 1 Then<br /> liveRounds\x = liveRounds\x + liveRounds\s<br /> Text liveRounds\x, liveRounds\y, liveRounds\i$</p> <p>For enemy.block = Each block<br /> If liveRounds\x &gt; enemy\x Then Delete enemy liveRounds\h=1 ; I changed this to add the flag H<br /> If liveRounds\h=1 Then Delete liveRounds</p> <p>;I added the above Line, I thought this would delete the bullet after it hit something<br /> ;However it makes a memory access violation and ends the program, i can't figure this out.<br /> Next<br /> End If<br /> Next<br /> End Function</p> <div class="content-separator" style="display: none:"></div> <p>Thanks alot u9</p> <p>-webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60336</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60336</link>
				<description></description>
				<pubDate>Sun, 21 Oct 2007 00:23:08 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Glad to help. Don't hesitate to ask again when you get stuck.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-60318</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-60318</link>
				<description></description>
				<pubDate>Sat, 20 Oct 2007 22:16:23 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>U9 Thanks alot i really appricate you taking the time to help me out with this. i've got a dance at school tonight but i am going to go over everything that you said in detail when i get home. Thanks again</p> <p>-webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-59284</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-59284</link>
				<description></description>
				<pubDate>Wed, 17 Oct 2007 23:19:32 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>i my self arn't all that great of a programer but i noticed something in the first line&#8230;</p> <p>Graphics 640,480,0,0 Set graphics mode and denote resoultion</p> <p>&#8230;you forgot to put in a semi-colon wher it looks like this</p> <p>Graphics 640,480,0,0 ;Set graphics mode and denote resoultion</p> <p>this is the fist problem i noticed, but i don't know if it will help</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-58968</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-58968</link>
				<description></description>
				<pubDate>Wed, 17 Oct 2007 07:25:07 +0000</pubDate>
				<wikidot:authorName>u9</wikidot:authorName>				<wikidot:authorUserId>12755</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I've been trying to look at this but there are some things wrong with it. createblock() and bullet() are probably not doing what they should&#8230;</p> <p>This is what you are currently doing (more or less):</p> <div class="code"> <pre><code>define types create player while not gameover create enemies and draw them move player draw player create bullets and move bullets wend</code></pre></div> <p>So all the time you are creating more and more enemies and bullets (although the bullets don't &quot;fire&quot; unless you press space, but they still get created).</p> <p>This is how you should do the game:</p> <div class="code"> <pre><code>define the different types (you already did this) create objects of those types (a player, some enemies, no bullets until player fires) while not gameover move player (based on input) if player presses space, THEN (and only then) do you create a new bullet (you can make a function createbullet() for this) move enemies (make a function who's only purpose is to move all the enemies) move bullets (make a function who's only purpose is to move all the existing bullets) check collision etc. (make a function who's only purpose is to iterate through all the bullets and check if they collide with an enemy) draw everything (this can also be a function) wend</code></pre></div> <p>Btw, the error with your posted code is this line:</p> <div class="code"> <pre><code>If bullet\x &gt; block\x Then End</code></pre></div> <p>Where the line is placed, neither bullet nor block exist as anything other than a type. To fix the problem you need (for each bullet) to iterate through all the enemies and see if, for any of them, the bullet has passed it. Like so:</p> <div class="code"> <pre><code>Function bullet() liveRounds.bullet = New bullet liveRounds\x = 0 liveRounds\y = shipy liveRounds\i$ = &quot;.&quot; liveRounds\h = 0 liveRounds\s = 5 liveRounds\f = 0 If KeyHit(57) Then liveRounds\f = 1 For liveRounds.bullet = Each bullet If liveRounds\f = 1 Then liveRounds\x = liveRounds\x + liveRounds\s Text liveRounds\x, liveRounds\y, liveRounds\i$ For enemy.block = Each block If liveRounds\x &gt; enemy\x Then End Next End If Next End Function</code></pre></div> <p>Note: i changed the name of the variable so not to confuse the variable with the type.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-58869</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-58869</link>
				<description></description>
				<pubDate>Wed, 17 Oct 2007 01:57:03 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>i am using blitz 3d. sry but when i pasted it into the thread it got alittle funky. i fixed it but once i click post it became sloppy. I have been working on it and the easiest thing to me seems to be to drop the functions and put everything in the main part of the program. I still would like to figure this out though and be able to use functions.I'll figure something out. Thanks for everything since i been at gdn,Hartnell your really helpful.</p> <p>-Webfaction</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-58562</guid>
				<title>Re: Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-58562</link>
				<description></description>
				<pubDate>Tue, 16 Oct 2007 15:15:31 +0000</pubDate>
				<wikidot:authorName>hartnell</wikidot:authorName>				<wikidot:authorUserId>10978</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I tried running this in BlitzPlus and it didn't work (even though you have cleared out the <tt>collision</tt> function.) I got &quot;Expecting end of file&quot;, which is a strange error.</p> <p>What Blitz product are you using? Blitz Basic proper has been dead for years hasn't it?</p> <p>Also, if I can't figure it out, stick around, I'm sure u9 can. &#8212;hartnell</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://gamedesign.wikidot.com/forum/t-23295#post-58528</guid>
				<title>Problem with collision in text game</title>
				<link>http://gamedesign.wikidot.com/forum/t-23295/problem-with-collision-in-text-game#post-58528</link>
				<description></description>
				<pubDate>Tue, 16 Oct 2007 13:57:41 +0000</pubDate>
				<wikidot:authorName>Anonymous</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>hi,</p> <p>I am having trouble with a text game I am working on. I am creating it using blitz basic.<br /> the game is basically a space invaders clone.<br /> i am going to paste my code below my question</p> <p>heres my problem, i have created two type statements, one for bullets and one for enemies(blocks). i the used to seperate functions to create them both and draw them to the screen. I want to check for collisons between the two but when i try to check for any collision between the two i get a memory access violation so i am assuming that they are both not in existance at the same time? i know this is a really vague description but i am having trouble understanding the problem. Thank you for any help.</p> <p>- webfaction</p> <div class="code"> <pre><code>Graphics 640,480,0,0 Set graphics mode and denote resoultion SetBuffer BackBuffer() ;Set the backbuffer ;------------------------------------------------------------------------------------------------------------------------------------- Global ship$=&quot;}&quot; ;The string that will be used to represnt the ship Global shipx=0 ;The ships x cord variable Global shipy=0 ;The ships y cord variable Global xspeed=2 ;The ships x speed variable Global yspeed=2 ;The ships y speed variable Global bspeed=10 ;The bullets speed variable ;------------------------------------------------------------------------------------------------------------------------------------- Type block ;Start The block type Field x ;The blocks x variable Field y ;The blocks y variable Field i$ ;The blocks image placeholder variable Field h ;The variable that represents weather the block hit an object End Type ;End type statement ;------------------------------------------------------------------------------------------------------------------------------------- Type bullet Field x Field y Field h Field i$ Field s Field f End Type ;------------------------------------------------------------------------------------------------------------------------------------- Function ship() ;Function that handles all ship actions If KeyDown(208) Then shipy=shipy + yspeed ;If the down arrow is pressed move ship down If KeyDown(200) Then shipy=shipy - yspeed ;If the up arrow is pressed move ship up If KeyDown(203) Then shipx=shipx - xspeed ;If the left arrow is pressed move ship left If KeyDown(205) Then shipx=shipx + xspeed ;If the right arrow is pressed move ship right End Function ;Close Function ;------------------------------------------------------------------------------------------------------------------------------------- Function draw() ;Function that draws everything to the screen Text shipx,shipy,ship$ ;Draws the player to screen End Function ;Close Function ;------------------------------------------------------------------------------------------------------------------------------------- Function createblock() ;Function that handles the creation of the blocks block.block= New block ;Create new block block\x=400 ;Set blocks x variable block\y= block\y+10 ;Set blocks y variable block\i$=&quot;[]&quot; ;Set the blocks Image placeholder value block\h=0 For block.block = Each block ;Starts loop that goes through each block created block\y=block\y+15 ;Adds 15 to the block\y value Text block\x,block\y,block\i ;Draws the block at its new position t=t + 1 ;Temp value = temp value + 1 If block\y&gt;300 Then ;If the blocks hit bottom screen restart at the top block\x=block\x-20 block\y=0 ;Move the starting x position over 20 End If ;Ends the current statement Next ;Ends the loop for the blocks End Function ;Close Function ;------------------------------------------------------------------------------------------------------------------------------------- Function bullet() ;Function that Handles all bullet aspects bullet.bullet= New bullet bullet\x=0 bullet\y=shipy bullet\i$=&quot;.&quot; bullet\h=0 bullet\s=5 bullet\f=0 If KeyHit(57) Then bullet\f=1 For bullet.bullet = Each bullet If bullet\f=1 Then bullet\x=bullet\x+ bullet\s Text bullet\x,bullet\y,bullet\i$ End If Next if bullet\x &gt; block\x then end ****( the above is the line i am using just to see that both are recognized if the bullet passes the block, i have tried placing it in several places but with no luck, i think its because the variables are both local and not global but they are in functions so i can't make them global. is there a way i can get a collision test to work without getting rid of the functions and making everything global? End Function ;Close Function ;------------------------------------------------------------------------------------------------------------------------------------- Function collide() ;Function that handles all collisions End Function ;Close Function ;------------------------------------------------------------------------------------------------------------------------------------- While KeyDown(1)=0 ;Start the Main Game Loop(MGL) Cls ;Clears screen createblock ;Calls the Function to create blocks ship ;Calls the Function that controls all ship aspects draw ;Calls the Function to draw the game bullet ;Calls the Function that handles the bullet collide ;Calls the Function that handles game collisons Flip ;Flip everythingthe backbuffer to the front and draw to screen Wend ;End the MGL ;-------------------------------------------------------------------------------------------------------------------------------------</code></pre></div> <p>edit : hartnell : code formatting fixed.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>