Game Help pls
Game Help pls
Game Help pls
Game Help pls
Game Help pls
Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls
Game Help pls Game Help pls
Game Help pls
Go Back  Xtreme Visual Basic Talk > > > Game Help pls


Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2005, 04:33 PM
N_S N_S is offline
Freshman
 
Join Date: Dec 2004
Posts: 32
Unhappy Game Help pls


First off, sorry for posting those other threads -- a quick search on the forum, and a little research, and I solved all my own problems.

That said, i don't know what to look for to solve this next problem. Basically, i got my space invaders game almost complete; just need the bullet to work usin pic box. I got it to work on key down and stuff....like, the bullet moves fine. When it reaches top of form, I made it disappear and reset itself. Problem is it doesn't always shoot from the tank (i.e sumtimes it shoots from other parts of the form). I tried using invalidate and makin the pic box move left and right with tank...but that doesn't work either (because the pic box moves even after initially shot). Basically i want it so that the pic box (containing bullet) will shoot from the tank when space bar is hit (no matter where the tank is on the form), but only continue straight up the form after space bar is hit. That way, next time space bar is hit, the bullet will again come out of the tank, and continue along an unaltering path until it is reset.

Help -- or direct me to some sort of tutorial plz If you need further clarification, pls just ask
Reply With Quote
  #2  
Old 01-06-2005, 05:56 PM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

have something like this in your timer
Code:
if laserisshooting laser.top = laser.top - 3 'whatevver else laser.left = tank.left + tank.width /2 - laser.width /2 ' so it will fire from the middle laser.top = tank.top 'make sure the laser is below the tank on your form design end if

this way, when the laser is not being fired, it will be always centered on the tank, and when it is being fired, it will only move up.

EDIT: when you finish, please post a copy, i would like to see it.
__________________
nerds unite!

Last edited by elnerdo; 01-06-2005 at 07:12 PM.
Reply With Quote
  #3  
Old 01-06-2005, 06:56 PM
theController theController is offline
Centurion
 
Join Date: May 2004
Posts: 120
Default

Quote:
Originally Posted by elnerdo
have something like this in your timer
Code:
if laserisshooting laser.top = laser.top - 3 'whatevver else laser.left = tank.left + tank.width /2 - laser.width /2 ' so it will fire from the middle laser.top = tank.top 'make sure the laser is below the tank on your form design end if

this way, when the laser is not being fired, it will be always centered on the tank, and when it is being fired, it will only move up.
yea this is the best way, just make your point location = the location of your tank

If your laser is not a picturebox (maybe decide this later). You can create a point and it would do the same basic thing as above,

laser.X = tank.Left + (tank.width / 2)
Reply With Quote
  #4  
Old 01-06-2005, 07:13 PM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

Mind if I ask, how are you making the aliens die when your laser hits them?
__________________
nerds unite!
Reply With Quote
  #5  
Old 01-06-2005, 07:40 PM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

He probably stops rendering that alien? :P.

-The Pentium Guy
Reply With Quote
  #6  
Old 01-06-2005, 07:42 PM
theController theController is offline
Centurion
 
Join Date: May 2004
Posts: 120
Default

Quote:
Originally Posted by ThePentiumGuy
He probably stops rendering that alien? :P.

-The Pentium Guy

Make sure you add a point to the score!
Reply With Quote
  #7  
Old 01-06-2005, 07:48 PM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

Just one? :P
Reply With Quote
  #8  
Old 01-06-2005, 08:20 PM
N_S N_S is offline
Freshman
 
Join Date: Dec 2004
Posts: 32
Default

Wow, thanks guys.

I'll have to try this out tomorrow (when I can get access to vb.net again).

And, to answer that questions bout makin the aliens die when hit:

I'm going to try to incorperate collision detection, so that when they get hit, sumthin will happen (i.e. add to score, show a blown up pic or sumthin, u know?). A little more research and some fiddlin around always helps!

Ill also take all of this into consideration.

Anyway, thanks again!
Reply With Quote
  #9  
Old 01-06-2005, 08:44 PM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

But how will he stop rendering that alien, the alien is a picturebox.

(Seriously, I want to know)
__________________
nerds unite!
Reply With Quote
  #10  
Old 01-07-2005, 11:40 AM
N_S N_S is offline
Freshman
 
Join Date: Dec 2004
Posts: 32
Default

Elnerdo, your question is the same as mine heh.

As it turns out, I got the bullet workin fine...now to hit the aliens! As you know, they are contained in pic boxes. All well and good, until i found out they cant get hit (or at least not by what I have done).

I tried fiddling around with the .left and .top properties (u know, if picbox1.left = picbox2.left type thing -- i realized that the only way this would happen would be if they were on the exact same axis of symmetry...). So, nothin seems to work. As I understand it, collision detection (intersectswith) doesnt work with pic boxes...

Is there a way I can make pic boxes detect collision (i tried search on forum..). Or is there another property that can be used? OR do I have to create a rectange and use intersectwith (if so, please elaborate because from what i've read, i'm still a little confused).

Thanks again
Reply With Quote
  #11  
Old 01-07-2005, 03:21 PM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

http://www.vbprogramming.8k.com/tuto...nDetection.htm

Elnerdo: I think you could a) Delete the image (Pbox1.image = nothing) or b) Delete the picturebox (pbox1.dispose)

-The Pentium Guy
Reply With Quote
  #12  
Old 01-07-2005, 03:37 PM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

but for his collision detection, he probably has something like
MY EXAMPLE:
if picturebox1.bounds.intersectswith(laser.bounds)

wouldn't this get an error if he simply deleted the picturebox?

and for making the image go away, wouldn't the picturebox still be there, and thus wouldn't the laser hit it over and over again?

and if you noticed my example, using .bounds will allow .intersectswith to work
__________________
nerds unite!

Last edited by elnerdo; 01-07-2005 at 03:44 PM.
Reply With Quote
  #13  
Old 01-07-2005, 04:34 PM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

He *COULD* use an IF statement to check it. But there ARE better ways of going about this(Instead of:
OMG CREATE 85 PICTUREBOXES ON THIS FORM! THEN CREATE 85 BOOLEANS FOR EACH ONE
IF PBOX1EXISTS THEN
IF PBOX1.INTERSECT(WHATEVER) THEN OMG DO SOMETHING
END IF
IF PBOX2EXISTS THEN
IF PBOX2.INTERSECT(WHATEVER) THEN OMGDO SOMTEHING"
END IF
(Don't ask, going a little crazy today)). I know a few people who actually ... erm... did that.

Ok, my recommendation (heh sorry for the above randomness)
Look into collections. That way you can simply remove add pictureboxes to your collections when you want (per level, read from a file). And then check for collision (collections will resize themselves and 'bump' themselves... for example
pbox1 pbox2 pbox3 pbox4

if you delete pbox2 then it would automatically make the list:
pbox1 pbox3 pbox4). And then remove them as necessary (MyCollection.Add(myPbox, "GreenAlienWithBigHead") to add them, and MyCollcetion.Remove("GreenAlienWithBigHead") to remove them.

To check for collision you'd do something simply like:
for i = 1 to mycollection.length 'Collections start at 1 for some reason
If DirectCast(MyCollection.Item(i), PictureBox).IntersectWith(whatever) Then
MyCollection.Remove(i)
End If
Next

-The Pentium Guy
Reply With Quote
  #14  
Old 01-08-2005, 08:43 AM
N_S N_S is offline
Freshman
 
Join Date: Dec 2004
Posts: 32
Default

Elnerdo,

thanks for your ideas with the .bounds.intersectswith('blah). So far, its worked the best. (I also tried some of the collision tutorials, but they seemed to screw up the game...i.e. using the bounding boxes method, all the aliens would die if one got hit :P).

Just one minor problem, which i am currently working on. Basically, when the aliens get hit, i want them to go away completely. I think this might be what you guys were debating about. You see, all that happens is the aliens images dissapear, but the pic boxes still seem to be there, because i can still hit them.

Thanks for your previous hlp though guys. If you want to hlp with this, be welcome! (Im workin on it myself though, finally got a version at home).

Oh and sorry for not postin in a while.

One more thing, I guess you were right elnerdo about the pic boxes not really goin away. i tried usin dispose(), but maybe that doesnt do what i want

Last edited by N_S; 01-08-2005 at 08:44 AM. Reason: Forgot something
Reply With Quote
  #15  
Old 01-08-2005, 08:49 AM
N_S N_S is offline
Freshman
 
Join Date: Dec 2004
Posts: 32
Default

Oops, think i might've just figured sumtin out. I'll post a bit later if it works!
Reply With Quote
  #16  
Old 01-08-2005, 09:33 AM
elnerdo's Avatar
elnerdo elnerdo is offline
Contributor
 
Join Date: Jul 2004
Location: Northern New Jersey
Posts: 490
Default

For a terribly inefficient method: you can move the aliens like 9000 pixels to the right when they're hit.

don't just go with this because it's easy though, pentiumguy's way is a LOT better
__________________
nerds unite!

Last edited by elnerdo; 01-08-2005 at 10:10 AM.
Reply With Quote
  #17  
Old 01-08-2005, 09:59 AM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

Or you can use a Collection like I said . It wil automatically "Take out" the alien you want to take out, and it will automatically "Sense" the fact that <X> alien doesn't exist and this <X> alien shouldn't be checked for collision detection with the laser.

-TPG
Reply With Quote
  #18  
Old 01-08-2005, 10:14 AM
Iceplug's Avatar
IceplugGame Help pls Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

I would recommend using an ArrayList instead of a Collection. Arraylists have more methods that you can use and I hear that they are faster.

Dim AL As ArrayList = New ArrayList(85)
Dim LV As Integer
For LV = 0 To 84 Then
AL.Add(a monster)
Next

By here you should have 85 monsters in the arraylist.
To loop through all of the monsters in the arraylist, you can do:
Dim M As Monster
For Each M In AL
'draw it if it is not dead.
Next

of course if you want to clear a monster, you can just do
AL.Remove(M)
and that removes the monster that matches the one that you assign.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #19  
Old 01-08-2005, 10:21 AM
ThePentiumGuy ThePentiumGuy is offline
Regular
 
Join Date: May 2003
Posts: 53
Default

The only problem I see with arraylists are that you HAVE to have a bound:
Dim AL As ArrayList = New ArrayList(85)

I also wish you can remove the Monster based on the KEY instead of removing it based on the actual .... monster.

This is an interesting debate...

-The Pentium Guy
Reply With Quote
  #20  
Old 01-08-2005, 10:26 AM
Iceplug's Avatar
IceplugGame Help pls Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

That's not a bound, that's the capacity.
If you go over the capacity, then the arraylist has to increase its capacity to hold more items (which probably causes a performance cut if you go over)... but going over capacity hasn't been a problem for me yet.

You can also remove a Monster based on its INDEX by using .RemoveAt
AL.RemoveAt(LV)
if you so happened to want to use a For Loop instead of a For Each Loop.
Dim M As Monster
For LV = 0 To AL.Count - 1
M = DirectCast(AL(LV), Monster)
Next

Note that if your monster is a structure instead of a class, then you have to reassign the monster if you update it, so it may be easier for you to use a class.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Game Help pls
Game Help pls
Game Help pls Game Help pls
Game Help pls
Game Help pls
Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls Game Help pls
Game Help pls
Game Help pls
 
Game Help pls
Game Help pls
 
-->