Allegro.cc - Online Community

Allegro.cc Forums » The Depot » Bloc! (a Tetris like game)

This thread is locked; no one can reply to it. rss feed Print
Bloc! (a Tetris like game)
Neil Roy
Member #2,229
April 2002
avatar

Game: Bloc! for Windows

Static linked allegro 4.4 game.

I mentioned this in another thread and managed to find a more up to date version. I had originally worked on this game back in 2003 and got away from programming and almost forgot about it. I found a backup I had made and I had almost forgotten that I worked again on this in 2009. This was originally going to be Shareware, I know, probably a stupid idea but... I was experimenting with how to implement Shareware and this was the project I tested it on.

Anyhow, this is a full version, incomplete as of yet but playable. Has a score, everything to do with game play is done, a lot of menu options aren't implemented yet, so clicking the buttons will do nothing. There are options, I don't recall if they all work or not, try 'em out.

It's like your traditional Tetris game, I took the time to do some nice looking blocks for this, not just plain squares. When you complete a line it reveals one more line of an image in the background behind the blocks. The level ends when you have the entire image revealed and play moves on to a new image, new level. There is midi music with this, the songs change as you play, they're not too bad, created by an online author I found and got his permission to use them. I can't recall his name off hand but I thought his music seemed to fit games fairly well.

The images are all family friendly if you just download the game itself.
There is an adult image set you can download separately if you're so inclined, the game will detect and use them by default if it finds them. ;)

{"name":"603865","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/0\/60c514fb4bf09fe3272c620bf6f2d4ce.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/6\/0\/60c514fb4bf09fe3272c620bf6f2d4ce"}603865

Bloc!_Allegro_cc.zip
Bloc!_Adult_dat.zip (requires main game to use)

---
“I love you too.” - last words of Wanda Roy

Mark Oates
Member #1,146
March 2001
avatar

Neil Roy said:

The images are all family friendly

:(

Quote:

There is an adult image set you can download separately if you're so inclined

:o 8-)

Quote:

(requires main game to use)

>:(

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Bloc! game said:

This application has failed to start because libgcc_s_dw2-1.dll was not found. Blah blah...

Luckily I have MinGW 4.5 installed, so I just moved the dll over and then it worked.

Revealing a picture is a neat idea. The look of the options menu widgets is off, they feel out of place. It would be nice to be able to rotate both directions instead of just one direction using the UP key. I alt-tabbed out of the game and the music froze. When I came back to it the screen was blank and nothing did anything. Also, after finishing the first level, the music just kept playing but it no longer responded to input.

Neil Roy
Member #2,229
April 2002
avatar

Wow, what is it with MinGW now and that fricken DLL?! That's annoying.

But like I said, it isn't finished, runs fine for me. I never tried to alt+tab out, I guess I'll need to throw in code to deal with that. ;)

I may have to dump GNU compilers, they're becoming an additional headache I don't need. I don't like the idea of learning to use Visual Studio, but I may have no choice.

As for the options, yeah, I noticed something was off on some of them. I had basically just recompiled it all with the new allegro and threw it up for sh!ts and giggles. I'll see what I can do... I think I'm done posting any further projects, at least until I can figure out Visual Studio 10 and compile it under a REAL compiler. ;)

Edit: Updated original post, I recompiled the game with an older MinGW (3.4.5), that should get rid of any dependencies for that dll. I moved ALL my DLLs in the Mingw\bin (stupid place to put them!!!) and placed them in a dll folder out of the path. I hate it when DLLs are put in the path because I can't tell if there's a dependency like this. This way if it needs a DLL, I will know about it if I don't have one in the project's folder.

Just don't ALT+TAB away while playing or you'll have to press ESC and then restart. ;) (I may fix that first I think)

---
“I love you too.” - last words of Wanda Roy

jmasterx
Member #11,410
October 2009

As much as I really enjoyed playing this, like I said to the other guy who made the 2d shooter game regarding the gui:

Quote:

One thing I noticed on my laptop is that when I tap in the menus, it does not click and show the next menu, but when I click it does. This means you are probably doing some type of input polling in your update function. You should instead opt for a more event driven technique so that tapping works. Personally, it sort of bugs me when a game doesn't let me tap :P

Quote:

The way I'd do it is, you set a flag when you get a mouse down, and set which rectangle the mouse is in, then when you get a mouse up you check if the mouse is still in the same rectangle, if it is, that is a click.

MiquelFire
Member #3,110
January 2003
avatar

This may be an Allegro thing actually. Combined with the drivers for the track pad. I know for a fact the scrolling on the track pads are not tracked by games as it's the track pad software looking for a scroll bar in the window and manually controlling it. Might be the same for the tap feature.

---
Febreze (and other air fresheners actually) is just below perfumes/colognes, and that's just below dead skunks in terms of smells that offend my nose.
MiquelFire.red
If anyone is of the opinion that there is no systemic racism in America, they're either blind, stupid, or racist too. ~Edgar Reynaldo

Neil Roy
Member #2,229
April 2002
avatar

Shouldn't tapping be treated the same as a mouse click? I mean, if tapping isn't going through when a mouse click does, that sounds a lot like a driver issue as tapping should act the same, especially on a full screen game. I could see how it might fail in a windowed game, if the mouse pointer was outside the window or something but... also note that many of my menus aren't implemented yet.

Update: Got some of the Alt_Tab fixxed (not uploaded yet), but still a few screens that don't update when you returm, so I need to edit those. man, what a job it is to add in support for alt+tabbing out... this is old code and I had screwed up in a few areas. Adding in alt+tab support really helped me see where my code needed re-organizing. I have to wonder what I was thinking when I looked at some of my functions.

---
“I love you too.” - last words of Wanda Roy

jmasterx
Member #11,410
October 2009

Tapping is the same as a normal click, except that the mouse down and mouse up are processed one after the other, before your update() is called, so then your mouse down / mouse up flag goes through a whole click sequence without your update even knowing. Whereas on a normal mouse, no human can click that fast, so it won't happen.

Neil Roy
Member #2,229
April 2002
avatar

I'm using the Allegro dialog for this (Allegro 4.4), I'm not sure how I could go about adding in the support you need. I wouldn't mind, would be a good exercise for me. I'm already thinking about how to implement this type of support for the game play as well, tap the screen to drop the piece (tap below it), tap to the right/left of it to rotate, hmmm...

---
“I love you too.” - last words of Wanda Roy

jmasterx
Member #11,410
October 2009

What you might want to do is queue mouse events and process them sequentially in your update();
Hmm but if you're using AL 4, might be tricky... Only thing I can think of is to poll the mouse at like 240 fps instead of 60

The thing about guis is they need to be event driven, when you get a mouse down, you flag the widget under the mouse as down, when you get an up, if the widget under the mouse is the same, you flag a mouse up and a click. A click tells your scene manager to change scenes, or flags an invalidated scene, where the scene is changed when update(); is called.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

jmasterx - you might want to check your touch pad settings - there may be a setting for 'tap to click'. I use input polling with A4.4 and tapping the touch pad works just fine with my GUI library, even double taps work like mouse double clicks.

jmasterx
Member #11,410
October 2009

Could it be because I'm running a MacBook Pro and BootCamp, and that Apple's drivers are bad?

In my gui, with AL5 I use events and it works like a charm.

I also noticed for example, in Humble Bundle, half the games tapped properly and half did not.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

jmasterx
Member #11,410
October 2009

I noticed that if I tap like a maniac, one in every 20 or so taps works, and this behavior is consistent with about 8 games. About 8 others work on the first go like my gui... hmmm

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Neil Roy said:

Wow, what is it with MinGW now and that fricken DLL?! That's annoying.

You can easily link statically with the C or C++ standard libraries, thus removing the need for that dll. Don't give up on MinGW just because their latest version of gcc does things a little differently.

Neil Roy
Member #2,229
April 2002
avatar

I haven't given up on it, just all the changes are getting annoying. I've bent over backwards trying to get in line with the new changes then this. I switched to an older version of MinGW, 3.4.5, I'll use it until they fix this mess. The current zip in the the first post contains the recompiled version (with MinGW 3.4.5) that shouldn't require any DLLs. I moved all my DLLs out of the bin folder (dunno why they go in there) so that IF one is needed, I should get the same warning as none of them will be in the path. Which is the way I prefer to do things so I know what to add to my zips.

I'm still locating all the places one can alt+tab out of and fixing them one by one. The GUI menu will be the biggest pain, I'll have to do that differently so I can redraw the screen if someone alt+tabs away... grrrr.... I'm trying to calm myself by looking at this as educational... ;)

Edit:

Also, after finishing the first level, the music just kept playing but it no longer responded to input.

Oh yeah, not sure what caused this on you. I never had this problem. When you finish a level it loads in level complete music and plays it while displaying the full image (without blocks in the way). Works for me on Windows 7+64bit. It's a pretty simple bit of code at that part of the game as well. Starts the music, displays the picture then waits for you to press a key basically.

#SelectExpand
1 if (old_level!=level) { // you finished a level 2 stop_midi(); // stop old music 3 play_midi((MIDI *)data[MUSIC_CLEARED].dat, TRUE); // play level complete music 4 5 // draw full image 6 if (ADULTMODE) { 7 if (image_selection==ADULT001) 8 draw_sprite(screen, (BITMAP *)image[ADULTZZZ-1].dat, 60, 40); 9 else 10 draw_sprite(screen, (BITMAP *)image[image_selection-1].dat, 60, 40); 11 } 12 else { 13 if (image_selection==IMAGE001) 14 draw_sprite(screen, (BITMAP *)image[IMAGEZZZ-1].dat, 60, 40); 15 else 16 draw_sprite(screen, (BITMAP *)image[image_selection-1].dat, 60, 40); 17 } 18 19 clear_map(); 20 while(keypressed()); // if play was still holding a key down, it waits for them to release it 21 clear_keybuf(); 22 while(!keypressed()); // wait for player to press a key to move on. 23 clear_keybuf(); 24 stop_midi(); 25 }

I've worked on adding alt+tab support in here, but ran into problems (code looks different than this now)...

---
“I love you too.” - last words of Wanda Roy

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

while (keypressed()) {}

If there is a key press in the buffer, that code will go on for ever... Just use clear_keybuf() and then readkey().

Edit
For alt-tab support, I just use a global buffer, and then when the program regains focus, I blit the buffer to the screen again. No need to do anything fancy really.

Neil Roy
Member #2,229
April 2002
avatar

This is an old project and to be honest, I don't know WHY I am drawing directly to the screen, but I am in this. I'll have to change that to a buffer and then do what you suggest. I normally use a buffer, I must have been drunk when I made this or something. ;)

Yeah, that keypressed() thing was a bad idea now that you mention it. The logic was that it would loop until you released the key, never even considered something in the buffer. Strange. I last worked on this in 2009, but started in back in 2003, big gap.

Edit: fixed that. Just added code to clear the buffer and wait for readkey(). Now to create that global buffer...

Edit: readkey() = no good because the program waits at readkey. INstead I went back to keypressed() only I left out the first one that caused problems.

      while(!keypressed()) {
         // check if alt+tab was used
         if(switched_in) {
            blit(buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h);
            switched_in=0;
         }
      }

This way if you alt+tab out, it will redraw the screen when you get back, with readkey() it won't.

Edit: Updated, alt+tab should be fixed in all scenarios (pauses the game when you do as well), compiled with mingw 3.4.5 so no dll issues. And that problem when you get done a level SHOULD be okay now.

Bloc!_Allegro_cc.zip

---
“I love you too.” - last words of Wanda Roy

Go to: