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 with c++ and DarkGDK?

Author
Message
shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 30th Apr 2012 00:46
I am in a introduction to c++ class and for a project with need to make a tetris game.

I need help getting started. I have no idea how to make the gameboard or how to start working on the shapes.

I would greatly appreciate any help.

shy wolf productions
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 30th Apr 2012 07:38
Well, to start, you could make a large background image that would have static information on it like text that says "next block" and "score". This image could also have the background for where the blocks will appear.

Ok, regarding mechanics... I'd recommend you make up a simple coordinate system that has a unit size of one tetris block. Then have a 2D array of the same size as the tetris board. In this array, let 1's mean a block is occupying that spot.

Then, for each block coming down, check to see if it hits a spot that has a 1 in it. If it does, just have it not move down and generate the next piece.

You should of course have some variables set aside to keep track of the current block.


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 6th May 2012 02:23
Here is what I have so far:




Not sure what to do in the classes


shy wolf productions
shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 6th May 2012 17:08
updated code:


shy wolf productions
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 6th May 2012 20:48
I can't really spend much time coding right now because of finals. I mentioned some ideas in my last post, but I won't be able to put up any example code for another day.


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 6th May 2012 23:05
I have until Wednesday to make at least one shape and print it on the screen. Final code is not due for 3 more weeks.

shy wolf productions
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 7th May 2012 18:10 Edited at: 7th May 2012 18:11
well, if you want to put a shape up I would just say to make a 2D array of the size of a tetris board. Then put 1's in a shape, and wherever you have 1's put a block.
012345

000100 0
000100 1
001100 2
000000 3
(This makes an l shape)
There is a 1 at (3,0) so multiply by say 50 to get the coordinates of the block that you will put on the screen.

Edit: For now, don't worry about classes. they are really not necessary for this type of game.


shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 7th May 2012 18:15
The instructions for the project require the use of classes.

shy wolf productions
shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 7th May 2012 22:02
This is what I have so-far:


I am getting this error:
Quote: "Error C2512: 'Shape': No appropriate default constructor available"


Here is the code:



shy wolf productions
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 8th May 2012 20:23

add "Shape ( void ) { }" after "public:", possibly add initializing in there if you want

Melancholic
14
Years of Service
User Offline
Joined: 26th Nov 2009
Location:
Posted: 8th May 2012 23:26
I have recently been programming Tetris in DBPro for a school CAS project, its pretty simplistic so far and is in a presentable state(don't expect to play a game of Tetris though), its just over 700 lines so far but you will only be interested in the functions that handle the core mechanics of the game, their all aptly named i hope



I plan to restart the project in GDK soon, provided that i can get the damn thing to compile...


I can count to banana...
shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 9th May 2012 01:56


Now getting this error:


shy wolf productions
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 9th May 2012 18:59
you forgot the { }, the error is saying that you used the constructor in I_Shape::I_Shape, but it can't find the body of the constructor, which, by adding the "{ }", is blank

shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 9th May 2012 20:44
Where does the {} go???

shy wolf productions
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 10th May 2012 17:53 Edited at: 10th May 2012 17:54


or even

just define a body, anywheree

shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 11th May 2012 00:55
I updated the code. I now get these errors:


NEW CODE:


shy wolf productions
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 11th May 2012 10:08
did you even read the errors? they're very obvious..
make_shape has no return type, neither in the declaration nor the body, and then you call make_shape passing 2 arguments while the function takes none

shywolf91
12
Years of Service
User Offline
Joined: 19th Apr 2012
Location: United States
Posted: 11th May 2012 10:15
I changed make_shape() to:

....
....
void make_shape();
....
....

This made the I_Shape, but it is not blue. It appears to be dark green/gray color.

shy wolf productions

Login to post a reply

Server time is: 2024-11-19 01:27:57
Your offset time is: 2024-11-19 01:27:57