Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Frogger Tutorial

Author
Message
starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 20th Feb 2010 09:10 Edited at: 20th Feb 2010 09:13
I was on Youtube tonight and I saw that there was a tutorial on how to make a simple game in dbpro called Frogger. Now we all remeber at on time or another playing this game on the old atari, apple and at the arcade, but having the chance to sit down and have it explained quite nicely how it works was a great tutorial.

In the amount of time he did the tutorial I made a game almost identical to his. I mean isn't that the idea of a tutorial? It got me interested in improving the game, since my fpsc isn't working right for me right now, I thought this would give me a chance to learn the code for future reference.

Now for my question on this. I have the code made, but I want to implement a menu, a new backdrop, level progression, timer and some images for the cars and frog. My question would be How do I go about doing this?

Also I seem to have a problem with the code. In the code when the frog gets to the otherside of the road and reaches the second pond the score is to increase by 1, but mine will increase continually increase them ore the frog stays in the pond. How do I fix that and how from that point do I make it go to say a new level?

Quite a few question I know, but before I leave this post I want those that want to learn to make a simple game like this in dbpro I plan to see that the code is left here in full for others to follow and to give credit to those that enjoy helping us of so little knowledge.


Here is the code I wrote for the game Frogger:



Screenie:


And to give credit where it is due here are the tutorials for this game.

Tutorial #1
Tutorial #2a
Tutorial #2b
Tutorial #3
Tutorial #4a
Tutorial #4b
Tutorial #5
Tutorial #6

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 20th Feb 2010 21:55
Quote: "Now for my question on this. I have the code made, but I want to implement a menu, a new backdrop, level progression, timer and some images for the cars and frog. My question would be How do I go about doing this?"


First off, I'm surprised this is done in 3D. The code still leaves some things to do. You should have five spots for the frog to end up at and once you get there another frog is generated at the start until all five are filled. Currently, you get to the second pond and the score just keeps going up. What happened to the water to cross and the moving logs / turtles?

You should be able to search the forum for the word MENU and get a number of ways that a menu can be done. A lot depends upon how much effort you want to put into it.

With DBP v 7.4, you can now simply texture the backdrop, so draw a backdrop in your favorite paint program, load the image and use it to texture the backdrop.

As to level progression, you have to decide what you want to make the game steadily harder; more cars / trucks on screen, moving the cars / trucks faster, etc.

You ask about images for the cars and frog, but these are 3D boxes. You would have to model something and load it into the game. If you do not have the modeling skills and don't know someone that does or don't want to pay for them, then you might consider making a 2D version of Frogger.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 20th Feb 2010 22:40
Thanks for your help. I can model pretty well, so that is not a problem for me. I will have a look at the menus on here.

Here is my next question, looking at the code that I have made, how do I load my models and how to load my backdrop?

Also in my first post I asked
Quote: "In the code when the frog gets to the otherside of the road and reaches the second pond the score is to increase by 1, but mine will increase continually increase them ore the frog stays in the pond. How do I fix that and how from that point do I make it go to say a new level?

"
Can anyone anwser this? I am fairly new to this cobebase and if you all don't mind the questions I will make atleast one complete game on this for others to follow.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 20th Feb 2010 23:07 Edited at: 20th Feb 2010 23:10
Quote: "Also in my first post I asked
Quote: "In the code when the frog gets to the otherside of the road and reaches the second pond the score is to increase by 1, but mine will increase continually increase them ore the frog stays in the pond. How do I fix that and how from that point do I make it go to say a new level?

"
Can anyone anwser this?"

You already increase the score by 1 - right after that reset the position of the frog to the beginning. Since you have hard-coded this as "Position Object Frog, 0, -500, 0", that would be the position to reset to. Since you check for pond(0) and pond(1), it increases your score by 2. I would only check for pond(0) and would get rid of the PondFlag variable.



starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 21st Feb 2010 00:00
Thanks you that will also help with level progression.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 21st Feb 2010 20:43
Quote: "Here is my next question, looking at the code that I have made, how do I load my models and how to load my backdrop?"


Models are loaded as objects. You have some choices available, but the standard method is:


Your model can only be loaded into DBP in the X, DBO, 3DS, MDL, MD2 or MD3 formats. Even then, DBP can be very picky. The textures for the model should reside in the same folder as the model itself so DBP can find them.


To change the backdrop with DBP v 7.4, you can simply load the image and texture the backdrop, like this:



Good luck with the project.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 22nd Feb 2010 00:51
I thank you very much. I have to go drive a truck snow plowing tonight, but in the morning I will definitely put this info to good use. Thank you again.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 22nd Feb 2010 07:29
Ok here is my current script of the game:

I have added sounds to make the game more lively.
My new question is why is my frog not showing when I load the mesh?

Which leads me to my second question How do I input sounds for the traffic where when the traffic is coming back on screen it honks?

Also I am still working on it how do I make the pond boxes transparent, but still act as goals?

I have included my files for which others can help out or learn with.

Attachments

Login to view attachments
starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 22nd Feb 2010 11:42 Edited at: 22nd Feb 2010 13:02
I have sat down to make a menu for this, but I have a to small issues.

Here is the code for the menu:






But now How do I get it to load the level and the savegame.dat?

Attachments

Login to view attachments
starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 22nd Feb 2010 12:14
I forgot to include the menu stuff for the data file.

Attachments

Login to view attachments
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 22nd Feb 2010 15:03 Edited at: 22nd Feb 2010 16:49
Looking pretty cool. Did you make the graphics yourself?

I didn't see the music file, so I remmed it out. In order for you to execute a file the way you have coded, it would need to be an executable file (i.e. with an .exe extension, not a .dba). Myself, I have always made menu selection a function or subroutine within the main code. Regardless of how you do it, I would suggest re-writing the code so that you are not using GOTO in your program.

EDIT: Why not do it like this?



The frog had to be rotated and scaled in order for it to be seen properly.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 22nd Feb 2010 22:39
I see...
So, I should have created my menu first and then the game?
Quote: "Looking pretty cool. Did you make the graphics yourself?

"

Thanks and yes I did make the graphics except for the frog and the logo frogger on the title page. The rest is just stock images that I had and I just made a quick title and level backgound after the tutorial.

I do have some more questions and I will lay them out for you all.I keep pressing F1 and scripting what I can, but these are the problems I am having.

1. How do I in the menu, do I load the savegame.dat in the game section of the code?

2. How do I make the cars honk when they reappear onscreen?

3. How do I start level 2 and so on?

4. How do I make the ponds invisible?

5. How do I make the frog use animation and rotate according to the keys I have laid out? I have 10 frames of animation to give that hop look.

6. How do I make the frog like one tile at a time?

7. How do I make it so the frog can like jump on a log and ride it?

8. How do I make it so if the frog misses the log he dies?

I think that is enough questions for now. I will keep doing my trial and error. So far I have shown will the help of others how to make a frogger style game from the tutorial of a simple game and now with all of your experience I wish to show how to make a complex game to get that retro feel.

Thanks for all your help and I hope there are some finding this useful.

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Feb 2010 03:26


There you are, I merged your menu with your game and also made some slight changes (such as the sounds that plays when you die or get a point so it doesn't pause the game). Also you will notice I made you frog a box because I couldn't get your .x to show up (I just made it a box for testing).

Quote: "4. How do I make the ponds invisible?"


Use hide object on the ponds.

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 23rd Feb 2010 04:49


Load game now works (only tested through the menu).

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 23rd Feb 2010 05:13 Edited at: 23rd Feb 2010 05:16
Thanks Hockeykid! I took what you did and combined it with what Lbfn and I had already. I am able to get the frog to show up now thanks to Lbfn.

I have attached the files in full this time. Just press play from the little Bit I have. With the frog in the static no bones.

I also have the new cars and buses for the new traffic. I also have the logs ready and two more level backdrops, but I will do more later in the morning.

Thank you both for your help!!

Attachments

Login to view attachments
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Feb 2010 13:51
A few comments if I may...

OK, your program might work at the moment, but it needs a little work - some cosmetic tidying up first though.

I keep banging on about correct indentation, but it really is important. I found the above code snippet quite difficult to follow without proper indentation, so I ran it through my DBATidy utility so I could see what's going on:



I'm sure you can now appreciate the difference and how much easier it is to read...

The next concern is the layout of the program. It's all back to front and makes finding and fixing problems more difficult than it should be.

Using this layout also forces you to use the dreaded Goto. This is in my opinion something that should be avoided at ALL costs if you want to avoid messy programs. Start your programs in a modular fashion and you simply don't need to use Goto at all.

Your main program loop should be the loop you sit in when playing the game. Main menu screens and hiscore tables should be subroutines you branch to with Gosub from the main program loop when necessary. (Don't believe anyone who tells you everything HAS to be functions).

For example, you would Gosub Main_Menu and sit in a loop until the user clicks the Play Game button. At which point, you initialize all the variables, set up the screen and Return back to the main program loop to play the game.

When the game ends, you simply Gosub Main_Menu again and sit waiting for the user to select something.

Rather than repeating everything I've already said elsewhere, here's a few links which explain things in a little more detail:

Program Layout

In-Game Menu Screens

Hi-Score Tables

These will also answer some of your additional questions.

The important thing though is to correct the main structure of your program now - before you go any further. If you don't, it will only come back a little later and bite you!

TDK

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 24th Feb 2010 02:32
Thanks Tdk!
I am having some issues with this bit of code.


I want to load the car and randomize the the textures or do I need to just make seperate loads for each car? I attached the new cars for the data file.

Also in the code I wanted the cars to honk as they come back on the screen, I got it to function properly. Here is the whole code again.



I don't know why, but I cannot get the frog to animate when when you press the button. I also tried to get it so that the frog moves in like tiles instead of the slow scoot it does. It failed so bad that I had to copy and paste the last working script just so I could try again.

So just to complete this level I wanted to show what I am using to reference with.
http://www.y8.com/games/Frogger_Classic

I want the movements to be like this game with the rotations, animations, and jump like movements.

Thanks and enjoy what I do have.

Attachments

Login to view attachments
starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 24th Feb 2010 03:43
Ok I have put the new animated frog in and one car using the multiplier, which gives me 5 cars bumper to bumper. I tried to seperate them with no success.

Here is the new code with the blue car and new frog.


Screenie:



I have also included the new frog model with ten frames of animation and the car that I flip around for this code.
So far I have things going the way I want.

Problems I am having are:

1. Cars bumper to bumper need to make them evenly spaced.

2. Cars textures to be at random.

3. Movements. This is important to get right with both sounds, animations, rotations and motions.

4. The five slot goal. need to be able to get the frog to clone itself once the frog in the goal slot.

5. Add blood particles to death to simulate being ran over.

6. How to go to next level?

I will keep my trial and error, but help is always nice. After I have level 1 ready to go to level 2, I will clean up my code.

The next levels will be basically a clone of this level, but the difficulty will increase to say a four lane highway, logs, more cars, gators, turtles and lily pads.

Thanks again for the help.

Attachments

Login to view attachments
Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 24th Feb 2010 05:05


There you are creates your cars (the more frame efficient way) and colors them all different colors.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 24th Feb 2010 06:57
Thanks hockeykid! What about spacing between them?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Feb 2010 01:06 Edited at: 25th Feb 2010 01:10
Quote: "1. Cars bumper to bumper need to make them evenly spaced."

Instead of having the cars the exact same way every time, why not consider placing cars randomly? This could be done by making your one-dimensional array, traffic(9) into a two dimensional array, traffic(9,6) - the 6 represents 6 different attributes that you could track (you can make this any number you want, obviously). To show what I mean, let's say that traffic(1,1) represents the object number of car #1 and traffic(1,2) represents the direction that the car is going. Personally, I use 4 for going right and 8 going left, but you can do it however you wish. Traffic(1,3) could be used as a status, like 0 means it is inactive and available for use or 1 can indicate that the car is in play and moving. Traffic(1,4) could represent a time that you want to expire before it's horn gets honked (if you wanted to do it that way. Traffic(1,5) could be used for the type of car. This assumes that you will have buses, vans, sports cars, whatev eventually. Traffic(1,6) could hold the color of the car if you wish.

The other cars would be accessed in the array by the first number being set to the car you want. So, car 3's direction would be placed in traffic(3,2). Car 7's object number is placed in traffic(7,1).

By doing this, you would have to check to make sure that the vehicles are properly spaced apart, which would take a little more coding effort, but would make for a much more fun game. If you really wanted to make it interesting, you could store different vehicle speeds in the array. For that, you would have to check to make sure you didn't run into another vehicle and to slow down, if it is the case. You see that there are many possibilities available to you.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 25th Feb 2010 05:08
Thanks I will hop right on that. So that I would put this in the move traffic function or do I make another function for this?

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 25th Feb 2010 05:52 Edited at: 25th Feb 2010 17:05
Any place in your code that has the traffic array currently will be affected by this change, so check all instances where it appears and make the adjustments.

The function Move_Traffic will change considerably, as you now will have to make sure that you don't place the cars too close together and that they will come out in a random fashion. It shouldn't be too hard, though. You are storing the direction of the car, so you move it based upon that. Once your x position moves the car completely off the screen, you change it's status to being available for the next random pick.

I would suggest writing out either on paper or in the code what the different parts of the traffic array stand for (i.e. traffic(x,1) = the object # of the car, traffic(x,2) = direction, etc. This would be a good habit to develop as you may set a game on the shelf for a while and come back to it later and if you have good notes it will make it easier. This is probably a good time to mention using rem statements in your code, describing what a function or subroutine or a particular line of code is doing. Some people tend to carry rem statements a little far, but it is good to remind you of what your intent with a particular section of code is.

I don't have much time tonight yet, but perhaps tomorrow I can post something else that will help you out.


EDIT: The collision stinks, but this is at least a working version of random car placement. You need to set up collision boxes for everything.



There are many different ways to go about coding. You have to decide which coding style is best and how you want to do things.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 26th Feb 2010 19:55
I am sorry for not updating this. I have been busy making a few things for CP's new pack. I will get back on this tomorrow. I have the computer rending a few things, so it should all be done in the morning.

starmind 001
FPSC Reloaded Backer
17
Years of Service
User Offline
Joined: 23rd Sep 2007
Location:
Posted: 4th Mar 2010 01:44
Lbfn I have inputed your code and it looks goo. I have just been working alot lately and I have just put things on hold for awhile.

I would encourage someone to show how to add a level and levels to the code. Also would like to show how to make better frog movements and show how to make the frog five goal slots. I have an idea, but some of what you see is just beginners luck. I am not great at writing code yet.

Also showing a way to jump on and ride an object like a log or lily pad.

I am only asking for this. I wanted to have a person who has just picked up dbpro and have this tutorial to follow and be able to tell whoever they want,"I made this game", but learn from it as well.

Thanks Lbfn and Hockeykid for your help!! I look forward to more of your help on this. For me and others.

feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 19th Mar 2010 08:18
Windows Game Programming For Dummies
or Tricks (of the Windows Game... blah blah)

Those are my recommendations for answering nearly everything you asked above.

A lot of this is math and algebra

Signed
------
MattyBoyIsBack
14
Years of Service
User Offline
Joined: 21st Apr 2010
Location:
Posted: 21st Apr 2010 21:03
sorry about puttin this in here but i couldnt think of anywhere to put it. i new to dbpro and i have a college assignment to do that im having trouble with. we have to create a game in dbpro. i havent got very far with it and was wondering if i can get some help...if so then let me now and i will put the coding on here..thank you in advance

Login to post a reply

Server time is: 2024-09-28 16:32:38
Your offset time is: 2024-09-28 16:32:38