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.

DarkBASIC Discussion / Tetris Game...which block sprites...???

Author
Message
Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 8th May 2003 16:50
A friend and I are working on a Tetris game here at school, and I've run into a problem. We have the blocks set up and the playing board, but I can't decide if it would be easier to simply cut one block out of the big blocks (One colored block for each big block. Each big blobk is a different color.) and dupe it to make the big blocks, so we could easily leave blocks behind after the player scores, or keep the big blocks, and cut out the smaller blocks in case a piece of block is left behind when the player scores. Basically, should I use little blocks to make big blocks, or should I keep the big blocks and use the little blocks only when something is left behind.
It's going to be just like the original Tetris. No colors matter, you just have to get blocks all the way across the board horizontally. Has anyone done this? (I'm sure someone has.) Do you mind if we take a look at some code?

Thanks,
Barrett
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 8th May 2003 23:57
Don't use big blocks. Just use a 2d array, 4 by 4 cells, that store the positions of the little blocks. Rotating is much simpler this way and involves a short for loop. When a block lands, add it's values to the gameboard array.

Well, there's lot more to it than that, but I hope it's a start. I made some source long ago for this, but I lost it: it was on my calculator anyhow.
freshalias
22
Years of Service
User Offline
Joined: 22nd Apr 2003
Location:
Posted: 9th May 2003 07:31 Edited at: 9th May 2003 07:33
Hop on over to 'Big Dan's page of brilliant assorted stuff' :
http://www.geocities.com/gaultd_81/darkbasic.html
Nice site, has a tetris game with example source *.dba.
Is this some kinda school assignment? x-d Well I guess it wouldn't be cheating if you went through the source line by line and made sure you understood it [b])

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 9th May 2003 16:42
Er...no...(whistles innocently)...
Haha...
yes, but we chose to do it at the end of the last couple of weeks...not really cheating...
Thanks,
Barrett

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 9th May 2003 18:43
Oh, BTW...the blocks are 50x50 per cell. They're BIG. We just want to make a small game...
we're on a two week time allowance, and we only have 1 left. (45 minutes per day.)
Basically, I want to see if we can do it in such short time. More source? (Without objects, we're working with the demo version...)

JB

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 9th May 2003 22:55
Set Display Mode 800,600,16
rem Set up Sprites
Load Bitmap "C:\tetclon\images\blocks.bmp",1
Get Image 3,0,0,50,50
Get Image 4,50,50,100,100
Sprite 3,250,250,3
rem Set up display
rem Load/Play Music
Load Music "C:\tetclon\music.mid",1
Loop Music 1
rem Set up background
Load Bitmap "C:\tetclon\images\blue_bg.bmp"
b=200
Do
Sprite 3,b,y,3
If Leftkey()=1 Then b = b-10
If Rightkey()=1 Then b = b+10
y = y + 10
Wait 225
If Downkey()=1 Then y=y+20
If y >= 550 Then End
Loop

That's what we have so far...
it took 2 days (An hour and 30 minutes) to make the background and the blocks. Now we're down to collision detection and grouping 50x50 cells to make shaped blocks...
feel free to play with the code...if you'd like I can paste the blocks and bg, etc...

thanks,
Barrett

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 9th May 2003 23:16
Here's some new work...
we've got the 2 sprites we have so far to randomize, and drop at different areas...the only problem is, when one sprite gets to the bottom, if it is the next to fall, then it leaves the bottom of the screen and returnes to the top! Is there anyway to make the sprite at the bottom stay as a different sprite (in this case it would be sprite 5 I'm guessing) and then return the falling block to the top (i.e. sprite 3 or 4)? If not we'll have to start all over...because there won't be any way to make enough sprites to ensure that block won't start disappearing, and I was planning on using sprite collision to make life easier.
CODE BELOW:

Set Display Mode 800,600,16
rem Set up Sprites
Load Bitmap "C:\tetclon\images\blocks.bmp",1
Get Image 3,0,0,50,50
Get Image 4,50,50,100,100
rem Set up display
rem Load/Play Music
Load Music "C:\tetclon\music.mid",1
Loop Music 1
rem Set up background
Load Bitmap "C:\tetclon\images\blue_bg.bmp"
b=200
goto randomblock
loop:
y=0
b=RND(799)
if b<200 then b = b +RND(200)
While y < 550
Sprite c,b,y,c
If Leftkey()=1 Then b = b-20
If Rightkey()=1 Then b = b+20
If b<200 then b=200
y = y + 10
Wait 225
If Downkey()=1 Then y=y+20
EndWhile
randomblock:
g=RND(1)
if g = 0 then c = 3
if g = 1 then c = 4
goto loop

Thanks,
Barrett

Pricey
22
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 10th May 2003 19:10
if it took you taht long to do that i don't think you're going to have enought time!

Do you mean that you are only allowed 45 mins per day!

[age 11]

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 12th May 2003 16:00
Yes, 45 minutes per day.

Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 12th May 2003 21:30
You're not going to get anywhere without using at least a game board array... and I also suggest using a current piece array, next piece array, and temporary array for rotating pieces.

Barrett
22
Years of Service
User Offline
Joined: 12th Feb 2003
Location:
Posted: 13th May 2003 16:13
Ok, well, I guess we'll have to use them then. 4 days left...
Barrett

Pricey
22
Years of Service
User Offline
Joined: 22nd Feb 2003
Location:
Posted: 15th May 2003 22:18
your're never gonna finish that

I don't know i can't tell!
I push the button and run like hell!
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 16th May 2003 01:16
it could be possible to finish it but I think you need a litle more DB programming experience

I tried to make tetris twice in the first days I used DB, but I didn't succeed... I had to stop each time because after some time I saw I made a fundamental mestake...
It was twice with sprites that I tried it. The first time a tetris block was just a whole sprite, not devided in smaller sprites. The movement and the placing of the blocks was okay, but when I wanted to start coding the removal of full lines, I saw it was only possible to remove bottom lines (by moving all sprites down)...
The second time I tried, I also used sprites, but I used seperate sprites for the little blocks in a tetris block... but because I was testing sprite collision it became too difficult to do it...
Now I'd just use an array and the paste image command (or 3d commands if you want to make it in 3d)

Login to post a reply

Server time is: 2025-06-14 16:02:31
Your offset time is: 2025-06-14 16:02:31