A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Major Flash game

  1. #1
    Junior Member
    Join Date
    Feb 2006
    Posts
    10

    Major Flash game

    I'm currently undertaking a major self directed flash based project for uni.
    My intention was to create a visually rich 2d shooter with dynamic bitmapdata based enemy damage and a dynamic physics based ragdoll system for enemy deaths.

    I have both of these features working, albeit in their early stages.

    My problem is that even in these early stages flashplayer is already beginning to struggle and I can forsee that it will completely choke if/when I try and combine these features with multiple bullets and enemies all at once.

    Here is an example of one of my bitmapdata damage prototypes:
    http://www.timdrew.com.au/shooter.html
    Gun follows the mouse, Ctrl = shoot, A,S,D - movement, Space = jump

    Try shooting the head.

    it is set to run at 20fps but isn't achieving that, atleast not on my computer anyway.

    The way it works is by creating a bitmap of the head image which is gradually erased. This is just the head, so I would need separate bitmaps for each body part (head, body, arm1, arm2, leg1, leg2) even more if you want the limbs to be able to bend.
    So every frame youve gotta do a hittest between each of those parts and a bullet along a number of intervals along the path of the bullet. Repeat for every bullet thats been fired then repeat the process again for every extra enemy onscreen, dont think its gonna happen.

    For the sake the game actually being playable I think I'll have to tone it down considerably, abandon the bitmapdata, probably the physics too cause it wont be worth doing without the rest and go for something much simpler.

    I'm thinking something like the Madness Interactive game, which is great, but has only superficial damage, simple character models and deaths.

    I think I might have been aiming a bit too high before, I could do it but not much point if its running at 5fps.

    I'd love to hear comments, suggestions, wise words from ppl who have dealt with processor intensive flash content b4 or better yet a solution that would see me salvage my current game idea ^_^ but thats probly not going to happen.

    As I'm most likely going back to the drawing board with my game i'm open to suggestions, ideas etc about topics, content, gameplay, gametype etc
    whats a good sort of game to make with flash keeping in mind it has to be a project of substantial size.

    Thanks ppl

  2. #2
    n00b LeechmasterB's Avatar
    Join Date
    May 2004
    Location
    Switzerland
    Posts
    1,067
    Hey did you post on the newgrounds bbs about this? I think i already discussed this tecnique with you for shooter use, and i am glad to see a working example as i did not have time to try it out myself yet. Its hard to say what is slowing it down it would help if i could have a look at the flash. If you want to show the fla i can try to find a way to make it run faster or find out what causes the major slowdowns... without knowing what code you used ect its not possible.
    There is not much on the stage so it should not run so slow at all! There must be ways to make it a lot faster.. It looks really good so far exept for the lack of performance it will rock if you keep on working like this!

    Some things to speed it up (if you have not already done so):
    Break the collision detection up into several parts.. going into detail. And if you did not already use filters and only one bitmap data per limb part.

    greets
    Last edited by LeechmasterB; 03-11-2006 at 01:35 AM.
    I do stuff that does stuff...

    J-Force

  3. #3
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    20 fps is too slow for any game. Most Flash games use 31 fps. Plus, every Flash movie played in the browser will lost about 10% of its fps.

  4. #4
    Junior Member
    Join Date
    Feb 2006
    Posts
    10
    Thanks for the quick response, yeah it was me.

    Guess I can give it a bit more of a go.

    I'm gonna try keeping the technicalities of the code to myself for now just because it's for assessment purposes so I can't really have anyone rewriting the code for me, otherwise id be all for it. Advice is fine tho

    Atm to find where a bullet hits, I have a long slender yellow mc that gets duplicated, as you can see when you fire the gun.
    In its first frame I use a do/while loop that incrementally goes through x values the length of the movie clip by 10px each time it conducts a bitmap hitttest to see if that point along the line hits the bitmap. This equates to 60 hittests in a single frame, just to see if one bullet hits one piece of the body.

    Can you think of a better way?

    Atm i test a certain point against the bitmap, apparantly i could test a rectangle against it but as yet havent got it working.
    A single test with the whole slender rectangle would be much better than a whole load of point tests.

    I don't understand what the point specifications within the bitmapdata.hittest() are for or how to specify a rectangle as opposed to a single point, flash support documents are terrible.

    Guess i'll keep slogging away, try and get it sorted.
    Last edited by Tim Drew; 03-11-2006 at 07:20 AM.

  5. #5
    n00b LeechmasterB's Avatar
    Join Date
    May 2004
    Location
    Switzerland
    Posts
    1,067
    I knew it was you ... well no problem if you can't post the code its just harder to help that way.
    Okay there are already some things you can do to improve it a lot but let me just write down how you can structure the hit testing.

    Step 1:
    You have a line going across the screen and the baddies are probably placed along the horizontal line/x axes. So you know that if a bullet hits it will be at a point where the y axses cross the x axes. So you only need to check areas where baddies are standing. So if you have a baddies x coordynate you check in only for a hittest with the bullet in the area of the baddie._x-baddie._width> pos < baddie._x+baddie._width .
    This will already give a big boost if the baddies are not placed all over the screen.

    Step 2:
    You check on which x height the impact is when you found the baddie it hits. And you only check the limbs of the baddie in that area.

    Step 3:
    You check which limb it hit.. or which bitmap data to do exact hittesting on.

    Step 4: You do the bitmap data hittest and like you mentioned yes it should also be faster by testing for a geometric shape instead of single pixles.


    I hope this helps, in case you have any questions just ask..

    Edit: Step two could be done by splitting the baddie into 2 or 3 sections hittesting wise...

    greets
    I do stuff that does stuff...

    J-Force

  6. #6
    Member
    Join Date
    Oct 2005
    Posts
    34
    I dont know how helpful this is, and maybe you've seen it, but Metanet have made some tutorials about hittesting and raycasting

    http://www.harveycartel.org/metanet/tutorials.html

  7. #7
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    Hey, well mine is running at about 16 fps, but I agree with what tonypa said. Most flash games fun at about 30-31 frames a second. If the majority of the people can't achieve that with your game, then I'd tone down the graphics a bit... (Madness was a good game, and it didn't lag because it didn't have that great of graphics)

    Good job on the graphics of your game though. They look great

  8. #8
    Iron Chef In-Training OpethRockr55's Avatar
    Join Date
    Sep 2005
    Location
    Kitchen Stadium
    Posts
    313
    I was planning on making a shooter with physics about three months ago, so I found a simple source and went from there to working physics with points and boxes (circles to come) and a newly created collision detection system for them.

    One thing I've learned from this is that physics+advanced graphics = trouble. I'm really concerned about you are going to achieve this with the rates you are running at the moment.... When you add your physics, you will have to redraw your graphics every movement the ragdoll makes, an extremely huge part of CPU if your game is graphically intensive. However, I'm not saying it can't be done.

    I, personally, would wait for Flash 9 and AS3 to come out before starting to add them all together.

    What you are doing is quite extreme. Your graphics, plus the ragdolls, plus the hittesting (I would suggest raycasting for this) equals devestation to the player's CPU.

    Just something to chew on for a while.
    Last edited by OpethRockr55; 03-11-2006 at 03:20 PM.

  9. #9
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    Set it to 30 or 40 fps and see how it goes.
    Also, why go so LARGE with everything? 600x500 is pretty big an dyour player is really large. Tone it down. Give Flash a little less to render. It will help greatly.

    Lastly, even though you say you use bitmapdata, your character seems to originate as a vector drawing? Try purely bitmaps and see how it goes.

  10. #10
    Junior Member
    Join Date
    Feb 2006
    Posts
    10
    Thanks for the responses everyone, I'm upping the framerate as recommended, also the stage size and character size aren't finalised yet as it is only in the early stages

    I wonder If I could get some more advice.

    I want to create a rectangle at runtime, then do a bitmapdata.hittest between that rectangle and a bitmap also created at runtime. a.k.a. test my long slender bullet rectangle against the bitmap making up an enemy body part, but a simplified model is fine for now.

    Anyone got an example I could look at?

    I tried the bitmapdata.hittest example from flash help which it says tests between a bitmap and a movieclip, I copied the exact code and tested it in a blank document but it appears that its only testing the point right where the mouse is as if you stretch the window and come in from the top or the left it doesnt register a hit when the shapes overlap, it only registers when the mouse touched the bitmap.

    I fear I am yet to fully grasp the way the bitmap data hittest works.

    Any chance anyone could give me a breakdown of the different entries within the hittest object

    aka:hittest(a, b, c).
    a: why on earth do I need to specify a point value within the bitmap? and what is the significance of the point value I specify?
    b: I get b, the opacity value thats straightforward enough.
    c: How do I specify a shape or object here? all I've been able to get working is a point value.

    thanks

  11. #11
    Junior Member
    Join Date
    Feb 2006
    Posts
    10
    never mind about the the hittest question, can't hittest a rotated rectangle so its pointless.

    I'll keep at it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center