Cervello
77 posts
|
Topic: Programming /
Problem Spawning Bullets
Originally posted by L3viath3nt:
Well, Unknown is right in that that is the problem. After using some traces I’ve determined that it doesn’t even attach a movieclip when going up and right, though all other directions work perfectly fine.
Anyway, I have found that strings are needed when it comes to animating the character, but integers are needed for the actually movement and such, so that is why I need a multidimensional array. (root.Buster.dir is actually 0 when facing left and 1 when facing right so by using it like this root.Buster.dirRay[_root.Buster.dir] I can add a 0 or 1 afterward, depending on whether I need a string or integer. This is root.Buster.dirRay’s definition:
dirRay = [["left", -1],
["right", 1]];
Gotcha.
That’s strange, though. I don’t see any reason in the actual create/attach code that would prevent specific directions from working. Maybe you shouldn’t call _root.getNextHighestDepth() twice when you use attachMovie, since it may be sticking objects named “1Bullet23” at depth 24, though it’s hard to imagine how that could be a problem right now.
var depth:Number = _root.getNextHighestDepth();
var bullet = _root.attachMovie(bulletType+"Bullet", bulletType+"Bullet"+depth, depth);
It may not help with your current problem, but it’s better for performance and may avoid future trouble, so you might as well try it.
I’m sorry, but so far I can’t find anything else that could possibly be wrong with the code you posted. Maybe you’re not setting _root.Buster.zone properly? If you already have code for the bullet that kills it or hides it when it leaves the screen and other stuff, are you sure it’s not being triggered somehow?
|
| |
Cervello
77 posts
|
Topic: Programming /
Problem Spawning Bullets
The only advice I can give right now is to use an integer instead of a multidimensional array for the player direction (I have no idea why you need to access a multidimensional array with _root.Buster.dirRay[_root.Buster.dir][1]; for this).
Example:
function bullSpawn(bullet) { //assuming _root.Buster.dir is an int either 1 or -1.
bullet._x = (_x + _root.Buster._x + spawnZones[_root.Buster.zone][0] * _root.Buster.dir);
bullet._y = (_y + _root.Buster._y + _root.Buster.upperBody._y + spawnZone[_root.Buster.zone][1]);
bullet._rotation = _root.Buster.zone * 45 * _root.Buster.dir;
//trace statements may help
trace("spawnZone coordinates: (" + (spawnZones[_root.Buster.zone][0] * _root.Buster.dir) + ", " + (spawnZone[_root.Buster.zone][1]));
trace("rotation: " + bullet._rotation);
}
I really can’t help you with your problem with just a snippet of code and no description as to exactly what kind of problem it’s causing. (Does it fire in the wrong direction? Does it not fire at all? Does it fire and not move? Have you tried debugging, or at least trace statements to try to figure out what went wrong where?)
|
| |
Cervello
77 posts
|
Topic: Programming /
Flash too slow?
Pah that game’s so small lol. Why does it even need to run at 60fps? You can’t really tell the difference.
Try it at x2 size then. The menu effects lag at that size, but actual gameplay is still smooth for me.
I don’t see why the size of the screen has any bearing on the fact that controls and animations are simply smoother at 60fps, though. (I don’t know about you, but they feel much smoother to me.) Pararalyzer has a 30fps option in the options menu, so try that for a quick, direct comparison. I get similar results when I try 30fps rendering with my game prototype.
I don’t really understand what that means “Create all instances of objects beforehand (ie: NEVER use the word “new” in your frame events).” because each new enemy needs to be a new instance….
I’m assuming you’re using a different class for each enemy type. Instead, you can simply make one Enemy class, and set a bunch of variables to determine what image will be displayed, what it’s stats are and what it’s OeF is. That way, instead of creating and destroying instances, you can “destroy” instances by setting them invisible and taking out/not running the OeF, then recycling it when you “create” a new enemy by simply setting all the variables again and making it visible. Have a pool of 100~200 instances ready in a list from the beginning, and you’ll never need to create or destroy.
You can do all that for bullets and particles as well, but those may need bigger pools than 100 or 200, depending on gameplay.
How (or whether, though I suggest it) you implement that is up to you, since there are plenty of ways to manage the “live” and “dead” instances.
|
| |
Cervello
77 posts
|
Topic: Programming /
Flash too slow?
perhaps you could link to a tutorial or such on this?
heriet (the maker of Pararalyzer) has a nice blog post outlining most of the ways she uses to make Pararalyzer work, but it’s in Japanese. And even if you can read it, it only goes through the stuff you do AFTER you get your rendering method straight – and that’s kinda tedious to go in-depth with.
I picked up almost all of my know-how by starting with that blog post and working with the as3 documentation and Google, but to summarize, the key points are:
- Use Sprites or Bitmaps instead of MovieClips. This means using BitmapData instead of vector-format drawings, though flash lets you save your vector drawings as bitmap images, which you can import to your library. Pixel blitting may or may not be better than using Sprites due to a bunch of factors – I went with pixel blitting, but performance wise they are pretty close.
- For Sprites and pixel blitting, use a static instance of the BitmapData instead of creating a new one for each.
- Create all instances of objects beforehand (ie: NEVER use the word “new” in your frame events).
- Use simple hit detection. (ie: rectangular or distance)
- Take advantage of the many general optimization tricks out there, like trig and integer math.
I’m not too keen on making a guide to rudimentary pixel blitting in Flash right now, even though Flash makes it pretty simple and friendly. I made a rudimentary implementation for myself, but I believe the PixelBlitz engine can do more advanced pixel blitting for you. But again, Sprites should be much easier to work with for those that are accustomed to MovieClips, and they’re probably just as fast anyway.
|
| |
Cervello
77 posts
|
Topic: Programming /
Flash too slow?
You have 500 movieclips running at 60fps, halve the fps and double the numbers. Also try to find a way to use less bullets. Anyway good game.
It’s ENTIRELY possible to make a 60fps bullet-curtain shmup with 500+ objects on screen run smoothly in Flash, even on average computers. See games like Pararalyzer for an example of this. Play it in Hard mode to see what I’m talking about. (Unfortunately, Pararalyzer’s a huge download due to unoptimized music, but it’s worth the wait.)
I happen to be making a 60-fps Flash shmup myself, but there are a lot of things you should (and probably need to) do to make this kind of thing work. I’m not going to go through all of them right now, but one thing you should do is to make a “pool” of pre-created MovieClips by creating a list of, say, 200~300 of them when the game starts, and toggle their visibility instead of creating and removing them. Also, Flash’s default hitTest is sloooow, and absolute hell if you run it hundreds of times to check the player’s collision with enemy bullets, let alone the thousands of times per frame it takes just for enemy and player bullets. I suggest you use the distance formula instead.
If I remade this code in AS3, would it be a lot faster, or is the difference not worth it?
Yes, it’s definitely worth switching to AS3, since not only is it faster than AS2, it offers the added flexibility and functionality you need to make more code optimizations possible (or at least much easier). Also note that MovieClips themselves can be slow when rendered in large numbers, so you may want to look into using Sprites or pixel blitting.
|
| |
Cervello
77 posts
|
Topic: Programming /
MouseEvent continuous AS3
Set a boolean to true on the mouse down event, and false on the mouse up event.
In your enter frame event or wherever, check if said boolean is true, and if it is, fire.
To add delays (I doubt you want to fire every single frame), define an integer to keep track of the number of frames that have passed since the last fire.
So together, it would look something like:
//variable declarations
var mouseDown:Boolean = false;
var shootDelay:int = 0;
//in mouseDown event
mouseDown = true;
//in mouseUp event
mouseDown = false;
//in OeF event
//if mouse is down and no delay left
if(mouseDown && (shootDelay == 0)) {
//reset delay, at 10 it will fire up to once every 10 frames
//at 30fps this is (theoretically) 3 times per second.
shootDelay = 10;
//fire
fire();
}
//if there's some delay left
if(shootDelay > 0){
//reduce delay
--shootDelay;
}
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
large scrolling background (6000px height)
well, yes, breaking the background into tiles theorically should do, but I dont seem to know how to perform this to avoid performance hit, hidding them when they are offstage wont make it more fluent…. any idea?
Here’s an example: Say you have a background 6000px high and you want it to scroll upwards and loop. Your game is, say, 500px high. You break the background into 10 different 600px slices (size doesn’t matter so long as each slice is longer than the game, in this case >500px).
One way to do this is to make a movieclip that has 10 frames, with each 600px slice on the same position in each frame.
- Put two copies of this “slice” movieclip (with different instance names, like “slice_1” and “slice_2”) on the stage.
- Keep two integer variables to keep track of the “slice number” you want each slice to be on (starting at 1 for slice_1 and 2 for slice_2).
- Put slice_1 so it’s top lines up with the top of the stage, and slice_2 so it’s top lines up with slice_1’s bottom.
- When the game begins, use gotoAndStop to set each MC’s frame to display the slice you want. (So slice_1 goes to frame 1 and slice_2 goes to frame 2).
- Move both slices up at the same speed. When one slice goes completely offscreen (first one to do so will be slice_1), increase it’s “slice number” integer by 2, then use gotoAndStop to set the image displayed by the MC to that slice, then move it’s position 600px down so it’s directly under the other slice.
- So slice_1 should now be on frame 3, and it’s top should be lined up with slice_2’s bottom.
- Keep doing this as long as you like. Just make sure that when the slice that moves offscreen is on frame 9, it’s looped back to frame 1. Same goes for frame 10, loop it back to frame 2.
…got all that? >.>
|
| |
Cervello
77 posts
|
Topic: Programming /
Help with anti-cheat code
A good catch-all anti-cheat method for a mouse game like that would be to test to see how far the mouse moved from its last position.
I coded up an an example that catches all mouse movements of more than 50 pixels. Tested and works like a charm – get the working .fla here. (You may want to raise/lower the threshold, since it may have false positives for really fast movements – but then again, who would flick the mouse around that fast in a precision game?)
This way, it doesn’t matter if they use right click, alt, move outside the screen, or do whatever other mouse movement cheat – if the mouse moves too fast or too far, this’ll catch it. Oh, and you can let players use the right click menu and stuff or accidentally hit alt without fear of mouse jumping.
Oh, and for future reference, you can find all the key codes here (there’s a table at the bottom)
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
some rules to follow if you are changing things during shootorials
I see miscommunication.
The .fla doesn’t need to be saved for your usual alt+enter testing needs.
All .as files, though, must be saved.
The name of a symbol can be the same as the class, in fact, I suggest doing so. The name of an INSTANCE of said object, though, shouldn’t be the same since it’s likely to cause needless confusion. (ex: For the MovieClip “Player”, you can/should use the class “Player”, but if you place an instance of it on the stage you probably shouldn’t call it “Player”.)
And try not to use the word “symbol” to describe non-alphanumeric characters in a Flash discussion.
|
| |
Cervello
77 posts
|
Topic: Programming /
AS3 Tip
To control the main timeline, and otherwise have a total equivalent of _root as you would with AS2, you need to use the “Document Class” feature. In CS3, just don’t select anything the Properties pane defaults to the document itself. Document Class is at the bottom left. Make the class some extension of MovieClip and you’ll be all set.
When you set the Document Class you can do the whole static var pointer thing in it’s constructor and have something like JustLikeRoot.main.gotoAndStop(frame); where JustLikeRoot is the name of the Class you put in for Document Class and main is the static pointer. You can also do JustLikeRoot.main.instanceName to access instances of objects without having to give them classes.
Just another thing I picked up from the AS3 version of Shoot.
|
| |
Cervello
77 posts
|
Topic: Programming /
AS3 Tip
Just to add on, I suggest you take a look at the AS3 source of Shoot! and see how they work around the lack of root. This is just a quick fix for a quick port to AS3. Even if you want to port AS2 code, things will most likely run smoother if you took the time and re-did it in AS3 the AS3 way, (that means very little copy and paste) and it’ll all be easier to use AS3 from then on. When in Rome.
In case it’s not clear (it wasn’t for me when I first looked <.<), in AS3 Shoot! they use a static pointer for classes where there will only be one instance of it at a time, and a static array for classes there will be multiple instances of. In the constructor of the class, it simply sets the pointer, or adds to the array, the new instance. That way, you can just say for example Ship.main, where Ship is the actual name of the class and main is the pointer. Or Ship.list[number] where list[] is the array (of pointers, sort of). As opposed to root.instanceName or icky stuff like root["instanceName"+number] which is pretty finicky even in AS2 (I assume there’s a better way but I haven’t stuck with AS2 for long.)
|
| |
Cervello
77 posts
|
Topic: Programming /
Events (e.g. MouseEvent.CLICK) Counting twice...how to clear?
I’d suggest using MouseEvent.MOUSE_DOWN and MouseEvent.MOUSE_UP listeners instead of CLICK.
Have one mouseDown boolean and one MOUSE_UP listener, and a MOUSE_DOWN listener in place of each CLICK listener you have. Use a quick if statement to make the MOUSE_DOWN code run only if mouseDown is false, then if mouseDown is false, set mouseDown to true, add the new listener, take the user to the next screen and remove the old listener. In the MOUSE_UP listener set mouseDown false again.
|
| |
Cervello
77 posts
|
Topic: Programming /
Shootorial Health Bar Help!
Well….I’m honestly clueless to exactly how you can screw up the change from:
function updateHealth(points)
{
health += points;
_root.healthMeter.bar._xscale = health;
}
to
function updateHealth(points)
{
health += points;
trace(health);
_root.healthMeter.bar._xscale = health;
}
But at this point I think you simply forgot to give the bar in the healthMeter Movieclip an instance name.
Also, consider editing your posts instead of double-posting.
You can even delete posts after editing!
|
| |
Cervello
77 posts
|
Topic: Programming /
Shootorial Health Bar Help!
You put trace statements before/after pieces of code to check that they’re running properly.
When you test the game, it appears in the output whenever the code goes through the trace.
For example, you would put trace(heath); after health-=damage; or whatever code it is that does that to make sure health is being properly reduced – if it is, the health would be outputted each time you take damage. Remember to take them out once your’re done with them.
|
| |
Cervello
77 posts
|
Topic: Programming /
Collab Petition!
/sign
Manual revenue sharing can only lead to conflict.
…but exactly how would automated sharing work with the $25 minimum payout?
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
""The class or interface 'ship' could not be loaded."- adobe flash- can someone explain wat i did wrong?" huh?.......its not letting me move the ship for some reason i have checked over and over (i am using CS4 would this make a difference?)
i downloaded the source?
i am a NOOB for i only started to day
Please, then, just do the Shootorials.
I’m sorry if I sound arrogant, condescending or otherwise down-talking-ish, but the Actionscript 3 source is there for people that have a grasp of Flash, Actionscript 2 and maybe some object-oriented programming, and want to learn Actionscript 3 by looking at a comprehensive port from Actionscript 2, because many people (including myself) found it difficult to transition from AS2 to AS3 using only the documentation and the random bits and pieces of code and advice found on the internet.
That source download is NOT for the people who “only started today” and have no clue how and why anything works. The Shootorials are there for that.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
Loading
It’s called a preloader, and yes, there are instructions, for Actionscript 2 or 3.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
In need of help. Powerups!
ok this has nothing to do with this topic
Then make your own topic.
Compiler errors like that tell you the line that’s wrong, so look there. If you still can’t figure it out, post that code in a new topic if you can’t figure it out.
You probably put your files in the wrong place, didn’t import properly or typed “ship” instead of “Ship”.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
In need of help. Powerups!
I see, forgive me for my language-ignorance :< (I should have figured that out with the //10 sekund, 100/(sekund*30))
That said, your problem with the shield image not reappearing after obtaining it a second time may be because you set the alpha to 100 while it’s not visible. I suggest moving the _alpha=100; parts to the activation code, on the line after setting _visible=true;, because visibility can interfere with changing alpha and tint and other such things.
Well, after you change the above, I suggest trying:
Adding a trace statement inside the if(_root.skjoldgrey.skjoldfarge._alpha < 0) conditional to see if it ever triggers. (like trace("setting invisible again");)
If the trace doesn’t trigger I’d suggest trying stuff like changing if(_root.skjoldgrey.skjoldfarge._alpha < 0) to if(_root.skjoldgrey.skjoldfarge._alpha < 1) or if(_root.skjoldgrey.skjoldfarge._alpha < 5), or using -=.5, just to see if Flash is stopping you from having negative _alpha.
If the trace triggers but the shield still works past 10 seconds, I’m clueless for now. Try if(_root.ship.shield._visible) instead of if(_root.skjoldgrey.skjoldfarge._visible == true) just in case, and check your other code to see if something else may be affecting the _alpha or _visible of those objects.
Another pointless note, when you use if() to test Boolean (true/false) variables like _visible you don’t need the ==true, you can just use if(_root.skjoldgrey.skjoldfarge._visible) for ==true, or if(!_root.skjoldgrey.skjoldfarge._visible) for ==false.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
In need of help. Powerups!
How do you activate the shield?
If I recall correctly the Shootorials use a pointer to the Shield movieclip and check to see if it’s non-null, so the activation should involve setting a variable in Ship equal to an instance of the Shield movieclip.
If so, simply set that same variable to “null” (without quotes, it’ll appear blue) in the deactivation code.
Oh, and I suggest using more logical names than skjoldgrey.skjoldfarge (like powerupDisplay.shieldIcon), it’ll help prevent typos and such, and helps people read your code when they want to help you. Also, capitalization like skjOldGrey or underscores like skj_old_grey will make it more readable.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
Dirty, Stinky, Evil Downvoters
The rating for my first game has been on from the beginning, and the rating steadily increased to 2.9X, then back down to 2.69 over the course of the contest. Judging by the overall number of ratings for each game, though, I doubt that someone could have inconspicuously created enough accounts to effectively downvote the other games. (I do see a number of level 1 downvote accounts, but that’s too little to do much damage. Then again, I only found them through the comments of entries, so there could be 200 more and I wouldn’t know.)
It’s just the busted way that Kongregate decided to run the contest.
Kong runs ALL their contests like this. (eg: Weekly/Monthly prizes)
It just doesn’t work nearly as well when you don’t have a good 70% of people who see the front page rating the games, or in a more contest-like setting. The Weekly/Monthly prizes are really contests in name only, and are more like prizes, but Scion has all the trappings and resultant problems of a contest.
Relatedly, Greg has said before that when he gives a badge to a game its rating usually plummets. More people == lower rating
Another main reason for the badge-bashing, imo, is that people feel forced to play games in a genre they otherwise wouldn’t even bother with. They obviously don’t like that genre and hence rate low. Also, any little problem with badges, or badges not being automatically obtained when the player played before, will gather plenty of hate-ratings as well. So it’s not just numbers that lower the rating, it’s the fact that it’s a badge game.
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
I don't get it...
Obviously, if it’s a great idea and it’s unplayable then that needs to be taken into account quite heavily, but games that have a lot of potential but are marred by a single issue can be thrown out without proper consideration.
Ah, if only I could go back in time and change the control scheme for Lumina. What really hurts about this is that nobody gives a damn if you fixed all their problems in an update, and if you reupload with minor changes to start with a clean slate you get bashed for it being too similar to what you already uploaded, so you’re doomed if it’s not awesome on upload. I, for one, liked my control scheme and had no idea that people would find it bad, and that pretty much doomed my entry.
Oh, and Draco, I don’t know what you did but I’m sure there are methods to making preset enemy spawns much easier for you (it took me only one day to set up all the waves for Lumina)
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
I don't get it...
If I had my way (and I won’t :<), contests like these would be judged by a panel of staff.
Not to say the current top 3 don’t deserve it, the’re all nice games, but when you sort entries by rating there’s games in page 7 that are arguably (or undeniably) as good or better as those in the top 10. If you go past page 2 of the ratings sort, the ordering is messed up as could be.
Why? Don’t average ratings work splendidly in the weekly/monthly contests?
Because average ratings simply don’t work as well as an indicator of quality in a minor contest like Scion, even if they do fine for the top 5 in weekly/monthly contests or all-time tops. The weekly/monthly contests are really a competition between games that get popular and spread across the internets to gather a storm of ratings. No Scion entry did anything remotely similar to that, save the one that some Norwegian gaming blog linked to. Like Salvator said, it’s a skewed population that plays and rates the Shootorial entries.
Another problem in using average ratings for the Scion contest, though, is that the mere fact that it’s Scion skews opinions one way or another. Some think “aww…it’s a first timer” and give 1 or 2 stars more than they’d normally give, while others go “A SHOOTING game? AGAIN? KILLKILLKILL” and give it a 1, or “It’s NOT a shooter? ORGINALOL 5/5” People will have a (more) biased reaction when they see that black background around your game.
But in the end, this can only devolve into an argument of whether or not impulsive ratings are valid, since impulsive ratings aren’t totally meaningless – like Aghannor said, SOMETHING must be making people recoil, even if it may seem to be a horribly stupid/selfish reason to the dev, or one they didn’t even think of as an issue. (My Dad bashed mine (Lumina) because he didn’t read the ingame instructions, clicked through the control/ship selects that explained the controls without reading, and tried to play it the same way as other shootorials, failed, and blamed the dev, so yeah.)
|
| |
Cervello
77 posts
|
Topic: Kongregate Labs /
I don't get it...
I don’t want to sound whiny, but every time I submit a newer game, it gets shot down even faster than the last.
Are the “improvements” I made really making the games worse?
Shoot+ Vector Storm (2.70 avg)
Vector Storm 2 (2.56 avg)
Lumina (avg worse than Click The Panda) – I noticed how many people simply dislike the control after showing it around in real life, so I guess it’s deserved in a way, but…Click the Panda?
|
| |
Cervello
77 posts
|
Topic: Programming /
Shun the nonbeliever!
Take him to your local computer, open any decent flash game on any browser, play a few levels/rounds and then right click on the game and show him the “About Adobe Flash Player” part. Repeat until it sinks in.
Or this. That should work.
Then again, the Shootorials would make your entire argument for you.
Ah, options.
|