Main Menu

frogger WIP , stuck a little?

Started by micky4fun, November 01, 2008, 06:50:39 PM

Previous topic - Next topic

micky4fun

hi all

well took your advice and started a frogger game Kevin , though as i am very new to this it would help teach me a lot ,
well im not doing to bad and quite pleased with the progress so far , a lot lot more to do and a lots of tiding up  ,

but im kinda stuck at the moment as in i can't seem to sus out why my lilly animations dont always seem to go in the order
they sould , is it my calculations or errors in doing it ?

;------------- LILLY ANIMATION ------ <<<<<<<<<
          lilly(n)=getspriteimage (n)
       if lilly(n)=> 22
          open(n)=open(n)+1
            if open(n)=150          
               ba(n)=ba(n)+1
                  if ba(n)=6 then ba(n)=0   
              spriteimage n,22+ba(n)          
              open(n)=0   
                 endif
                 endif

lines 154 to 164 and also lines179 to 189

any help on this will be great by Kevin or anyone else
also if you can see any other way i can improve my programming bits so far



thanks
mick

kevin

#1
  You didn't have to make a frogger game, but i'm glad you did.  As it looks really good so far!

 As for the animation problem, I can see where you're coming from, but i'm not too sure I follow your logic.   Anyway, if the lilly frames are loaded as images 22 through to 28.    We can just 'step through the image numbers to cycle the lilly sprite animation.   A bit like this.

PlayBASIC Code: [Select]
             ;------------- LILLY ANIMATION ------ <<<<<<<<< 
img=getspriteimage(n)
if Img=>22
open(n)=open(n)+1

if open(n)>=50
open(n)=0
; bump the frame
Img=Img+1
; check if the frame is beyond the lilly animation frames,
; if so, reset to the starting frame 22
if Img>28 then img=22
; update the sprite
SpriteImage n,Img
endif
endif




 I'm not entirely sure what you're using the ba() array is being used for.   It seems to be the frame counter in the animation.  You could certainly do it like this, but if we're going to storing information about each object in the game then it's generally better to store all of the objects properties in the one place.  So things can't be confused, or corrupted if our programs logic is bit wonky.  You're already doing this with  typed Car() array.  However, by expanding on this approach we could manage all of the objects in a more generic fashion.    

 If you want, i'll knock up an example for you pick through.  

micky4fun

Hi Kevin ,

great stuff , yep i can see what i did wrong now i over complicated things with the (lilly) arrays and (ba) arrays , yep the (ba)
was my animation frame counter , but i can see your way is nice and easy , i think i got so mixed up in the way i was doing it
that i did'nt see the easy way ,

quote "However, by expanding on this approach we could manage all of the objects in a more generic fashion.   

  If you want, i'll knock up an example for you pick through
"

yes when you get time it would be nice to see another way of doing it , for this program and will also help a lot
for other future projects

i may change the images in the final version , got lots to do yet but wanted to sort this problem out first , been 2 days trying to sus it out , ended up quite simple in the end ..

once again Kevin thanks for your help with this and the very quick reply to my problem

mick

;D

kevin

#3
Quoteyes when you get time it would be nice to see another way of doing it , for this program and will also help a lot
for other future projects

  Done.. Threw together a version this afternoon.  It uses your GFX, but I wrote the code from scratch.    Mostly to demonstrate another way of attacking the same problem.   In my version, i've used a typed array to hold all of the moving game opponents within.    Each cell in the OBJ() array represents all of the information about each on screen character.   The game engine distinguishes between objects by using ID's.  in this case the ID's are some numeric constants.     So a LOG has a LOG ID an CAR the CAR ID etc..    The game engine simply runs through and updates all of the game objects in one main loop.  Inside here, we can handle the variations between the different objects types, such as the Lily animation etc.   When the player interacts (hits something) we can suss out what type of object we're hit than react accordingly.  So if stand upon a LOG, we move with the log,  if to hit a car we die.. If we stand on a lily, we move with it, until the animation is invisible, if so, we die,  if not, we're ok..  So we're just plugging the logic together.

   also added collision and a basic frame work to the game, so the player can die, reach the goals,  earn points, level up and end the game.  So the basic mechanics are in place, but it's not too pretty.

  Also SEE ->  Play Frogger Example



ATLUS


micky4fun

Hi kevin ,

well what can i say the customer support that you give is second to none , thanks for doing it the proper way and posting code ,
as i know the way i did it was well around the houses so to speak and sloppy to a real programmer .
i will print and study your version and try to see whats happing as im totally new to all this , and to be totally honest your program does look a little daunting to me at a first look , im upto nearly the same stage as you now , how you did this in an afternoon is amazing in my opion , but i know you are an expert ( top man )

but i hope to try and sus it out and hope it brings some help to others on forum as well
i will finish the game as soon as possible and post up final version , i did promise a twist to this game and hope to comply to this
my dodgy programming permitting , lol

i have a few game ideas and will start then soon after finishing this frogger
one thing i haved learned is to think out and draft a up something first , as i just went staight of the block with this game and did come up with a few problems .
also before i do anything else i need to learn the sprite collision commands as did take me a while to sus some basic ones out

thanks again Kevin for your time in doing your version , i will try to use some aspects of it in my future projects

regards
mick  ;D ;D ;D

kevin

#6
Mick,

Quotewell what can i say the customer support that you give is second to none , thanks for doing it the proper way and posting code ,

    I really don't think there's proper way, but there's definitely a wide spectrum of approaches, which is what I was trying to demonstrate.  Namely the usage of Typed Arrays,  functions and differently control mechanisms such as the Select/Case, repeat/until,  etc .       What you'll find, is that over time you'll develop you're own style.   This is a good thing, as long as you don't get limited by it.


Quotei will print and study your version and try to see whats happing as im totally new to all this , and to be totally honest your program does look a little daunting to me at a first look , im upto nearly the same stage as you now , how you did this in an afternoon is amazing in my opion , but i know you are an expert ( top man )

   Well, yeah I've been doing this for a long long time now.  However,  knocking up the program code is much easier when you have a clear concept & the artwork is sitting in front of you.   From there, it's much like putting a jigsaw puzzle together.   This bit goes here, this goes there etc etc.   Programming is far more difficult to do without a single tangible idea in place.  Sitting in front of a blank screen, waiting for some grand inspiration isn't the way to get something done. 


Quotebut i hope to try and sus it out and hope it brings some help to others on forum as well
i will finish the game as soon as possible and post up final version , i did promise a twist to this game and hope to comply to this
my dodgy programming permitting , lol

    Go for it ! -  Every time you visualize something and then put it into practice, the easier this will all become.  The more you do it, the more you start to see patterns and overlaps  in how many game types work (old & new). 

    As general point (not directed at you):   There's a bit of misnomer about game programming.   All too often people jump into this, thinking they'll be able to create something along the lines of their favourite game today.   Even though modern tools  have vastly simplified the programming process, this is just not reality.    Modern games require a vast conceptual knowledge.  However, so do retro games.   The latter however is made much simpler today by the tools, and thus are a much more favorable way to learn the necessary concepts (Ie. Game mechanics).

    So my advice to anybody struggling is look to the past, if you want to have a programming future.

monkeybot

thats handy 'cos i am stuck firmly in the 80's

micky4fun

hi Kevin

Yes i can see how typed arrays are can be very useful and other commands stated , i will try to expand on my first game frogger , but to be very honest i did not expect to get this far when i first bought PLAY BASIC
as i did'nt really have any other prior knowlage of programming in basic or other language than just a simple print "hello" and a for next loop , but im very please with the outcome so far , but then again most of the hard work is done by your program.
yes i dont expect to be writing the latest games , im very happy and over the moon to be how to put together a rather simple 80's type game , as you advised me frogger was a very good place to start , i have an old atari 800xl tucked away with every game that came out on it , i will get it out soon and go through some of the games for ideas , soom classic games on there ,
miner 2049er springs to mine and jet boot jack to name a few , but i have an idea for a postman game that i will start soonish .
my girlfriend plays a lot of the 2d games on zylon , dinner dash etc , these type of games are rather good i think and i expect would be well within the realms of PLAY BASIC , but maybe not me , but well worth me having a bash at i think !

ok lets get frogger finished and posted up

thanks agian for all your help and advice
and also thanks to other forum members for there posts which i love going though

mick   :)

kevin

  Mick,

QuoteYes i can see how typed arrays are can be very useful and other commands stated , i will try to expand on my first game frogger , but to be very honest i did not expect to get this far when i first bought PLAY BASIC as i did'nt really have any other prior knowlage of programming in basic or other language than just a simple print "hello" and a for next loop , but im very please with the outcome so far , but then again most of the hard work is done by your program.

     Well, It takes two to tango.  Tools are  part of it, but having an open attitude is much more important.  Can't think of too many people who are well on there way to making a couple of games within, their first few weeks of programming.  That's all you !
     
Quoteyes i dont expect to be writing the latest games , im very happy and over the moon to be how to put together a rather simple 80's type game , as you advised me frogger was a very good place to start , i have an old atari 800xl tucked away with every game that came out on it , i will get it out soon and go through some of the games for ideas , soom classic games on there ,

       Frogger was just one that came to mind, prolly better examples around, but couldn't think of any.  You'll find that even in old retro games there's some really very clever design/programmers around.  Never had an Atari machine myself, was on the C= side of the tracks.   Either way they're a perfect place to find ideas.

Quoteminer 2049er springs to mine and jet boot jack to name a few , but i have an idea for a postman game that i will start soonish

     Go for it.  Don't recall seeing jet boot jack actually. 


Quote.my girlfriend plays a lot of the 2d games on zylon , dinner dash etc , these type of games are rather good i think and i expect would be well within the realms of PLAY BASIC , but maybe not me , but well worth me having a bash at i think !

     What's zylon ?



micky4fun

#10
hi Kevin

(login required)

time limit games or buy outright

mick

kevin