The Daily Click ::. Forums ::. Klik Coding Help ::. shooting an object faster than the default max amount 100?
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
12th August, 2011 at 21:59:24 -

is this possible? or would i have to do some sort of crazy coding to get it to do that?

 
[Game design makes my brain feel like its gonna explode.]

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14456

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
12th August, 2011 at 22:55:45 -

Not crazy coding, but you would need to actually code something entirely different from a built in movement.

A stupid example that sort of explain my point would be if you had an event to move the bullet (or whatever you're shooting) 1 pixel then copy that 101 times. Job done.

If you're shooting the object in two directions, left and right it's easy to use a loop to move and detect collision on an object as many times as you like. If want 360 degree shooting you might want to look into trigonometry.

http://www.create-games.com/article.asp?id=764
This may help you ^

 
.

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2722
13th August, 2011 at 17:57:31 -

In other words: you need to code it yourself instead of using the built-in action.

You can then move the 'flying object' yourself by manipulating it's position.

For horizontal or vertical movement it's rather simple: just add or subtract from the x or y position. For example: x position = 200, add 100 and x will be 300 and the 'flying object' has moved a 100 pixels. And of course you can set the number pixels yourself, 100 isn't the max here.

For directional movement read about trigonometry or use Pythagoras theorem if you know at what point you're aiming.

Happy coding!

 
Image jenswa.neocities.org

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1331

VIP MemberStarSnow
13th August, 2011 at 22:08:58 -

If it's just simple two-directional movement, couldn't you simply:
Test for bullet object in play area, test for left direction on player object, then set bulletX - current bulletX -2 or -3?
You'd have to set up a second event to test the player character facing right, then set bulletX to current bulletX +2 or +3.

Then you could destroy the bullet as it leaves the play area; but this whole method could really screw up collision detection, as the bullet is basically skipping 2 or 3 pixels as it's being shot. If it collides with an object less than 4px wide, there's a chance no collision would occur. Bullets would also get "lodged" in walls and any background objects set for collision.

It's a quick and dirty way of accomplishing your goal, though.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49978

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
15th August, 2011 at 06:15:45 -

OK, this is easy.
There are multiple ways of doing this, but I find this to be the most accurate, and dependable way.
If you (or anyone else) needs further explanation for why this method is the best just ask.

Your bullet object should have some named variables first:

BulletXOrigin - the X position from which the bullet shoots
BulletYOrigin - the Y position from which the bullet shoots
BulletSpeed - how many pixels per loop the bullet moves (Higher = faster)
BulletDirection - the angle the bullet is traveling
BulletMove - the distance from the "spawn" point that the bullet has traveled

Then add this event:

Always-
- Set X Position of "Bullet" to
BulletXOrigin("Bullet")+cos(BulletDirection("Bullet"))*BulletMove("Bullet")
- Set Y Position of "Bullet" to
BulletYOrigin("Bullet")+sin(BulletDirection("Bullet"))*BulletMove("Bullet")
- Add to BulletMove of "Bullet"
BulletSpeed("Bullet")


Done!

 
n/a

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
16th August, 2011 at 05:09:45 -

thanks everyone for your input! really great ideas im not to worried about actually putting this in my current project seeing as 100 bullet speed is perfectly fine, i was just curious.
To The_antisony: that wouldnt work for my current project Celestia, as you can shoot at any angle, but for some of my other games that would work great, thanks!

 
[Game design makes my brain feel like its gonna explode.]
   

Post Reply



 



Advertisement

Worth A Click