00:00
00:00
I-smel
Hey look man, my name's "I-smel". What I lack in smarts, I at least pay back in honesty. Boink!

Tom Brien @I-smel

Age 32, Male

England, MAN-CHESTer

Joined on 3/2/06

Level:
1
Exp Points:
10 / 20
Exp Rank:
> 100,000
Vote Power:
1.50 votes
Rank:
Civilian
Global Rank:
> 100,000
Blams:
0
Saves:
17
B/P Bonus:
0%
Whistle:
Normal
Trophies:
12
Medals:
473
Supporter:
11m 29d
Gear:
2

New way to shoot

Posted by I-smel - September 5th, 2008


I just came up with the greatest way to shoot in a Flash game ever. I'm pretty sure I'm not the first guy to come up with this.

What I've bin doin so far is; I've bin makin the game produce a bullet whenever you click that flies across the screen. Like in CannonCrotch, you see a bullet, you see it moving, and you see it hit an enemy or wall.
Contra does this, Metal Slug, Alien Hominid, tonnes o games.
In reality, bullets aren't that slow. Bullets are fuckin quick.

So what I've done is, I've pre-determined every position the bullet would ever be in, then produced a hundred bullets that each occupy one of those positions. FUCKIN TIMEWARP.

Observe:
http://spamtheweb.com/ul/upload/060908 /7441_YeahBabyGoYeah_Allright.php

Click to shoot. Use WASD to move around.

Here's the chode:
onClipEvent (mouseDown) {
hit = false;
for (i=1; i<=30; i++) {
if (!hit) {
duplicateMovieClip(_root.shot, "shot"+i, i);
xshot = (i*20)*(Math.cos(R*(Math.PI/180)));
yshot = (i*20)*(Math.sin(R*(Math.PI/180)));
_root["shot"+i]._x = _x+xshot;
_root["shot"+i]._y = _y-40+yshot;
if (_root.ground.hitTest(_root["shot"+i].
_x, _root["shot"+i]._y, true)) {
hit = true;
_root["shot"+i].removeMovieClip()
}
}
}
}


Comments

Awesome...
*bookmarks*

THATS BRILLIANT MAKE IT A GAMEAERESTRHT

hmm. my friend! Just use one big rectangle for all the range of the bullet!!

Well your friend's an absolute fucking docile bastard.

pretty realistic, definately alot more like an actual bullet than slow moving projectiles.

I'm sorry.

assuming your mans instance name is MAN, put this in the frame in which he belongs

var cosNum:Number = (Math.cos(R*(Math.PI/180)));
var sinNum:Number = (Math.sin(R*(Math.PI/180)));
function onMouseDown(){
var hit:Boolean = false;
var i:Number = 0

while(!hit && range<30){
var BP:Point = new Point(MAN._x+(i*20)*cosNum,MAN._y+(i*
20)*sinNum)
if (_root.ground.hitTest(BP.x,BP.y, true)) {
hit = true;
trace("HIT AT RANGE:"+range + " AT X POSISTION:"+BP.x+ " AND Y POSISTION:"+BP.y)
}
}
}

same code - far less CPU intensive - although there are still better ways of doing it.

Whoopsy doodle, this is AS2, so no point class

use just generic object instead

var BP:Object = new Object(....

Whoopsy doodle version 2

Man I'm failing tonight

here be the real code

var cosNum:Number = (Math.cos(R*(Math.PI/180)));
var sinNum:Number = (Math.sin(R*(Math.PI/180)));
function onMouseDown(){
var hit:Boolean = false;
var i:Number = 0
while(!hit && range<30){
var BP:Point = new Point(MAN._x+(i*20)*cosNum,MAN._y+(i*
20)*sinNum)
if (_root.ground.hitTest(BP.x,BP.y, true)) {
hit = true;
trace("HIT AT RANGE:"+i + " AT X POSISTION:"+BP.x+ " AND Y POSISTION:"+BP.y)
}
i++
}
}

That's a great thing, thanks. :DDDD