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 / My first game ever (need help)

Author
Message
Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 2nd Aug 2010 20:03
Hi, all!
First, I wanna say that I'm new to this forum and to the DBP.
I have no programming experience, but I like this program very much
so I started on my game.I didn't get very far so I need your help.

This is what i have for now...


So, as you can see, its not much for now.
I want this game to be a game where you have to avoid the incoming
enemies. But the problem is that nothing is incoming (yet).
So I hope that someone will help me to do it.
THANKS in advance!

=)Please don't laugh, I'm new.=)
Zorkonian12
14
Years of Service
User Offline
Joined: 28th Jul 2010
Location: Why would I tell you?
Posted: 3rd Aug 2010 01:11
Wow. Pretty good. Better than I can do right now!

I don't really know any code that could help you, but you might be able to get some tutorials from various websites.

badkneecap
14
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 3rd Aug 2010 05:19
It's extremely important to lay it all out from the beginning. As simple as it may be, draw out a flowchart and write down what it is going to do. That way, you can create the different part and test them individually. Think of the game pong. Extremely simple. 2 paddles, 1 ball. Both people start at 0, player scores when ball reaches top or bottom of screen, player wins when score reaches 10. Once player reaches 10, start over.

Once you complete your game, then you can think about pong 2.0. But I can't stress how important it is to finish what you started. Don't be that guy who starts 10 games and doesn't finish any of them. As simple as it may be, there is nothing like creating a game that someone else can play.

So, your first step is to tell is what YOU want it to do. What controls you use, how you win, etc.
NightX
15
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 3rd Aug 2010 05:59 Edited at: 4th Aug 2010 08:12
Hey.

1. Welcome to the the forums

2. Some stuff could be improved for speed ->





could be cut down to the following using a FOR loop:





also the line function can be changed to do the same thing like so:





and insted of re-drawing the circle EVERY loop, you can draw it once before the MAIN loop, grab a image of the circle, turn it into a sprite to move around, and use that for colisions.
You code now would look like this:






Nooww for the enemies.

You have to make a.. eg box, get an image of it, then make a sprite with it (in the loop), and using ur Data Type (Enemy.x / enemy.y) and use the RND(value) command to randomize a value for your x position (rnd goes from 0 to you input value) then move your enemy down (inc enemy.y,1) or (enemy.y = enemy.y + 1).

Then use Sprite Collision(Sprite1,Sprite2) to check if there was a colision between the 2 sprites (yours and the enemies) if not do nothing else eg end the game or say "you lost". and if the enemy gets to the bottom of the screen. reset its y position back to the top of the screen, and randomize its x position.

(this is for 1 enemy only) for 2 or more, you would have to change Enemy as ObjectData to Dim Enemy(10) as ObjectData This will create an array of enemys, all with x and y integers.

then in your loop, dont just update 1 object, make a FOR loop, and cycle through all of your enemies and check colisions between them, reset their position if the enemy gets to the bottom ect.

Example:


Hope I Helped.

Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 3rd Aug 2010 11:21
1. Thanks Zorkonian12 !

2. Badkneecap, I've already said what I would like to do in this game. Move the player and avoid the enemies.
But thanks for the advice anyways!

3. Thank you very much NightX, you really helped my.
I'm going to try to make the enemies now.

=)Please don't laugh, I'm new.=)
Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 3rd Aug 2010 13:36 Edited at: 3rd Aug 2010 17:14
NightX, you really helped me.
I have maneged to make one enemy, but I'm having little trouble making allot of them.

This is my code for one enemy now...

This one is for multiple enemies(doesnt work)


Could you please tell my what is wrong with my code?
THANKS !!

=)Please don't laugh, I'm new.=)
NightX
15
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 4th Aug 2010 04:18 Edited at: 4th Aug 2010 08:15
Alright, i see afew thinks you are doing wrong.

1. At the start of the code you have:


you are trying to use the x variable to set all of you enemys to a random position. and x = 0 (1, there is no enemy we are using with an ID of 0 and 2. this will ONLY SET 1 ENEMYS POSITION NOT ALL OF THEM. see, you have to use a For - loop to set all of them using the variable x like so:



2. Get image, this isnt a problem that you arnt using it, its very simple once you understand it. Get image - Parameters -> Image ID,x1,y1,x2,y2,Texture FLAG The Get Image Command will GRAB a SQUARE piece of your screen and save it as an image (it only is tempory, it dosent save it to the computer in a file, you use a different command to do that), its like Load Image but, you just need to put the ID you want the grabbed piece of screen to be and the position/size ect. The texture flag is if its FILTERED or not, filtering makes it LOW quality, but faster im sure (filtering = 0, nothing (good quality = 1))


3.(read 4 before you start editing this or your other update code)Your trying once again to paste the:
in your loop. You need to make sure this in the UPDATE LOOP so it can UPDATE ALL of the enemys.

4. You have to re-arange your update loop like so:
1. Inc y position
2. Show SPECIFIC sprite
3. check if it needs to be repositioned
4. Check Colisions


And also, with your sprites, you can ONLY paste 1 Sprite at a time which we will have to make 10 sprites, 1 for each enemy, starting at ID = 2.(if you arnt using the paste sprite command which dosent have collisions).

So since your first enemy sprite starts with the ID of 2 (since your player ball is 1) you need to paste 10 sprites + 2 so each one can have collisions:

This is in the Update Enemy Loop AT THE VERY START.

now just use the SpriteID as your sprites ID :

You can edit to how you need it, its just to show how it works.

That Should work. If it dosent, ill re-look over it.

This is my Code:


Matija the n00b
14
Years of Service
User Offline
Joined: 2nd Aug 2010
Location: Croatia
Posted: 4th Aug 2010 11:20
Wow, man!
You really like helping, don't you?

Well thank you very much! I have made some minor changes to your code, set enemies random speed and stuff like that.

Now I have my(yours) very first, working game!!!

THANKS!

=)Please don't laugh, I'm new.=)
NightX
15
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 5th Aug 2010 09:58
haha no problem, just hope you learned something from my code and explanations for your future game(s).

Happy coding

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 5th Aug 2010 12:37
I tidied it up a bit and changed the ball() so you can give a colour for the ball, you could also change it so you can give the co-ordinates and radius of the ball so you could draw any type of ball anywhere on screen!


NightX
15
Years of Service
User Offline
Joined: 3rd Apr 2009
Location: Australia, QueensLand
Posted: 5th Aug 2010 14:37
Obviously the code could of been improved, but for a quick tut it was how it was.

Login to post a reply

Server time is: 2024-11-23 10:52:48
Your offset time is: 2024-11-23 10:52:48