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.

Dark GDK / Tetris Clone

Author
Message
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 26th Nov 2007 21:23
Hey,
I'm making a tetris clone and I've got 2 questions for ya all.

1. How do I randomize what block it will place.
2. How can I tell it ta stop when it gets to a certain point on the screen? (screenY)
3. How can I make a block go through the transparent part of another block so that like an L could fit into another upside down L and form a square with no gaps.L.
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 26th Nov 2007 21:34
Hey Cooldude

1) You make a list of your blocks and take a random number of that. Then you choose the block from that.

2) If you are using sprites then you just stop move that sprite when it reach the screenY coord. And then you init a new sprite with the new shape.

3) Because you are usign sprites then you test for collision betweem sprites. If there are no collision then you can just continue the "drop-down".

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 26th Nov 2007 21:58
Neils,
Can you explain 1 and 3 some more???
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 26th Nov 2007 22:21
Sure

1) You have lets say 10 bricks. You need to choose one random. In the language you are using you have a random function. That choose a number from 1 to 10. Thats the brick you need to choose.

3) In DGDK you can test for spritecollision. When that happend you need to stop the brick falling down. There will be some more tests, but thats the idea about it.

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 26th Nov 2007 22:34
Yo Niels,
I still don't get it. Do you think you could add a couple things into my code?? If so here it is...



Thanks!!!
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 27th Nov 2007 15:31
Cooldude - I dont program in C++ (Im a .NET geek).

I can see that you are busy with a lot of projects... focus on one project at the time..

I cant help you with C++ code but I can help you to think about the problems you have and then you can find the code by yourself. The architecture of a game is the same no matter what language you are using

First you need to be able to do this:
1) Drop a brick down from top to bottom
2) Let the user move the brick from side to side using keys
3) Let the user "fast-drop" the brick with "SPACE"
4) Try to see when you have a collison betweem 2 bricks.

When you can do this 4 parts then let me know

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game
A1 Programmer
16
Years of Service
User Offline
Joined: 20th Nov 2007
Location:
Posted: 27th Nov 2007 19:59
The simplest way to handle movement and collision is to create a grid system... The grid will represent the game window (where the puzzle pieces are actually placed).

Figure out the size of your puzzle pieces. Make this equal a single grid element...

Based on your game window width/height... figure out how many pieces can fit vertically/horizontally...

Create a 2D array to store the grid, and set each element to 0, meaning no piece is there.



int width = 8
int height = 12;

int arr[8][12];

for (int x=0; x < width; x++)
for (int y=0; y < height; y++)
arr[x][y] = 0;



It's much easier if you only allow the piece to move in the x and y direction by the width/height of a piece.

You can easily examine your 2d array to see if a piece already exists where the new piece is trying to move... If so, stop moving that piece, update the array to now have the new piece.

If you want to get crazy, you can use different values for different types of pieces.

Hope this helps a bit!
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 27th Nov 2007 22:16 Edited at: 27th Nov 2007 22:19
A1 Programmer,
So what your saying is that if my screnn display mode is set at 800x, 600y and my peaces are 25 pixels each that I should like have 32x Grid Spaces and 24y Grid Spaces and my code would be:




Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 28th Nov 2007 03:55
Ok Guys. What I want to happen now is the programs drops a block and it lands at the bottom of the screen. The block that i'm dropping is a 25x 25y PNG image. I got it to stop but then I goofed up my code and had to erase it. It dod work at one compile time. I can't figure out how I made it stop. Any ideas??? Heres my code:









I anyone who will help me!!!
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 28th Nov 2007 14:28
Hey, I got my blocks to stop when they hit the bottom now!!!! If you want ta look at my code here it is!!!



Cellbloc Studios
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location: Atlanta, GA
Posted: 28th Nov 2007 17:30 Edited at: 28th Nov 2007 17:31
I have NO clue if this is going to confuse you (Actually, I think it may very well but I'm trying to get your number of new post for help of your Tetris clone less than 2 a day) but here is a link to the Tetris Source Code written in C++ that you can use as a reference.

http://tetris.source.code.googlepages.com/

Your mod has been erased by a signature
jasuk70
21
Years of Service
User Offline
Joined: 3rd Dec 2002
Location: Hemel Hempstead
Posted: 29th Nov 2007 10:52
Cooldude. I recommend you take a step back from this game and start to work your way through the tutorials that come with DGDK. This may help you get an idea about how to use the DGDK. A good way to understand how things work is to start changing things inside the tutorial code to see how it affects when you run it. I'm not sure but maybe the Space Invaders one is a good one to do this on as I think this uses sprites and moves them around etc. This should hopefully give you ideas on how to create your Tetris game.

Jas

----
"What is this talk of 'release'? Klingons do not'release' software. It escapes leaving a bloody trail of developers and quality assurance people in its wake!"
Cooldude
17
Years of Service
User Offline
Joined: 10th Nov 2007
Location:
Posted: 30th Nov 2007 01:10
Hey,
Jas, I have already tried the Dark Invaders tutorial but do not understand it very well. Are there any other tutorials that explain all the steps in creating a 2d Game???
Niels Henriksen
20
Years of Service
User Offline
Joined: 27th Sep 2004
Location: Behind you breathing heavely
Posted: 30th Nov 2007 13:18
Cooldude - then split up the tutorial in small parts and try to understand them. Change them and see what happend.

Then you will learn better

Niels Henriksen
Working on a (MMO)RPG right now in LightEngine
http://noggs.netopcom.dk/forum/default.asp - Forum for the game

Login to post a reply

Server time is: 2024-11-19 17:30:06
Your offset time is: 2024-11-19 17:30:06