Skip navigation
GKelly642
Currently Being Moderated

Need some help making a game

Mar 30, 2012 6:47 PM

Hello, i'm creating a game with Director using Lingo. Basically its a game which has targets moving down the screen at random horizontal positions. Currently i have 5 target sprites with the script below attached to each of them. I want to make the same thing but only use 1 target sprite however i'm not sure how to go about this. I want targets randomly being created at a random intial vertical location then for them to go down the screen. You'll see what i mean in the link to the game below. Thanks any help is appreciated even some pseudocode on how i would go about solving this problem would be useful.

Thanks Graham.

 

Game link: http://www.andkon.com/arcade/adventureaction/targetmania/

 

Lingo script currently attached to 5 target sprites:

property pSprite, pVInitLoc, pHInitLoc, pEndLoc, pSpeed

 

on beginSprite me

  pSprite=sprite(me.spritenum)

  pVInitLoc=-50

  pEndLoc=650

  pSpeed=random(1,4)

  pSprite.locV=pVInitLoc

  pSprite.locH=(random(10)*50)-25

end

 

on exitFrame me

  pSprite.locv=pSprite.locv+pSpeed 

  if pSprite.locV>pEndLoc then

      pHInitLoc=(random(10)*50)-25

      pSpeed=random(1,4)

      pSprite.locV=pVInitLoc

      pSprite.locH=pHInitLoc

    end if

end

 
Replies
  • Currently Being Moderated
    Mar 31, 2012 7:14 AM   in reply to GKelly642

    why only one sprite

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 31, 2012 10:00 AM   in reply to GKelly642

    Coding and sprites are two different things. The game you link to uses way more than 5 sprites. Using many instances of a single script is efficient. It means you can make one change in one place, and it will affect all the targets.

     

    Writing code that will simulate multiple sprites in a single sprite is not efficient. It's re-inventing the wheel.

     

    Perhaps you could talk to your tutor about what s/he means by "efficient code", and revise your approach accordingly.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2012 7:29 PM   in reply to GKelly642

    you shouldn't use sprite behaviors for a game

     

    sprite behaviors are similar to flash components, it's a tool for application design

     

    more, 99% of simple games are totally procedural, no object class are requiered

     

    so you'd better use an entry point in a global script ("movie"), then from it, call your engine hart in a static class ("parent")

     

     

    another error: do not use exitFrame/prepareFrame/stepFrame events for a game routine.

    use enterFrame instead, this event is called when cpu is free, between 2 render steps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 2, 2012 7:54 PM   in reply to Owen Buddenbaum

    Owen, I can agree with you about using enterFrame... in most cases. (It is perfectly fine to use stepFrame if no changes are made to sprite display or positions within the stepFrame event).

     

    However, I cannot agree with your statements:

     

         you shouldn't use sprite behaviors for a game

     

    and

     

         more, 99% of simple games are totally procedural, no object class are requiered

     

    These statements make me think that you have not explored behaviors or object-oriented programming sufficiently, and that you do not understand the benefits of using these techniques. Perhaps you would like to elaborate on your opinion?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 29, 2012 8:25 PM   in reply to James Newton, ACP

    Sorry i made an error,

     

    the correct sentence is:

     

    "99% of procedural games are totally procedural, no object INSTANCES are required"

     

    for procedural programming, use static classes. no movie scripts because of a garbage collector issue, excepted as en entry point

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points