New Game: Block Boy

Use this forum to share and discuss Uzebox games and demos.
User avatar
L4rry
Posts: 239
Joined: Sun Dec 28, 2014 7:19 am
Location: Cape Town, South Africa

Re: New Game: Block Boy

Post by L4rry » Sun Aug 27, 2017 2:17 pm

I am finally a Block MAN!! :D What an incredibly addictive game. I've managed to beat the last of the 14 levels today. Levels 9 through 11 are real ball breakers. It really gives you a sense of achievement once you complete the game. This is actually the first Uzebox game I've played end-to-end. I haven't been giving enough attention to playing the existing catalog. I'm aiming to change that. Next up, Bugz!

User avatar
D3thAdd3r
Posts: 2422
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: New Game: Block Boy

Post by D3thAdd3r » Sun Aug 27, 2017 5:31 pm

Glad you enjoyed it! The library is so large now, it would definitely be many hours of gameplay to play through half of it. Pretty amazing really.

User avatar
uze6666
Site Admin
Posts: 4449
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: New Game: Block Boy

Post by uze6666 » Fri Sep 22, 2017 4:00 am

A too large library of games to play...what an awesome problem for us!! :D

User avatar
Artcfox
Posts: 945
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: New Game: Block Boy

Post by Artcfox » Sun Mar 11, 2018 6:51 pm

I was hoping to learn how you implemented a camera system in a mode 3 scrolling game, so I tried compiling Block Boy from its source code, but ran into a visual glitch caused by undefined behavior in C, and a slight error in the Makefile which prevents the make command from building it.

In the Makefile, UZEBIN_DIR is set to the gconvert binary inside the tools directory, rather than the bin/ directory. Once fixed, I was able to build a .uze file, but there are visual glitches caused by undefined behavior in the DrawMetaSprite function.



In C, the order in which function arguments are evaluated is undefined, and in the DrawMetaSprite function, foff may be incremented before the lookup in sprite_frame_table is performed. Indeed that is what was happening to me when compiling it using avr-gcc version 4.9.2 included with Debian 9:

This is what allowed me to get a clean and working build:

Code: Select all

diff --git a/BlockBoy/BlockBoy.c b/BlockBoy/BlockBoy.c
index d505412..79b0172 100644
--- a/BlockBoy/BlockBoy.c
+++ b/BlockBoy/BlockBoy.c
@@ -293,9 +293,9 @@ void SetSprite(int16_t x, int16_t y, uint8_t t, uint8_t f){
 void DrawMetaSprite(int16_t x, int16_t y, uint8_t f){
 
        uint8_t foff = f*4;
-       SetSprite(x+0,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
-       SetSprite(x+8,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
-       SetSprite(x+0,y+8,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff++]));
+       SetSprite(x+0,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff])); foff++;
+       SetSprite(x+8,y+0,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff])); foff++;
+       SetSprite(x+0,y+8,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff])); foff++;
        SetSprite(x+8,y+8,pgm_read_byte(&sprite_frame_table[foff]),pgm_read_byte(&sprite_mirror_table[foff]));
 }
 
@@ -1186,4 +1186,4 @@ GAME_TOP:
                }
        }               
        
-}
\ No newline at end of file
+}
diff --git a/BlockBoy/default/Makefile b/BlockBoy/default/Makefile
index d473437..71c6f47 100644
--- a/BlockBoy/default/Makefile
+++ b/BlockBoy/default/Makefile
@@ -19,7 +19,7 @@ MIX_PATH:= $(realpath ../data/sounds.inc)
 MIX_PATH_ESC:= $(subst $(SPACE),$(SPACE_ESC),$(MIX_PATH))
 
 
-UZEBIN_DIR = ../../../tools/gconvert
+UZEBIN_DIR = ../../../bin/
 ## Kernel settings
 KERNEL_DIR = ../../../kernel
 KERNEL_OPTIONS  = -DVIDEO_MODE=3 -DSOUND_MIXER=1 -DINTRO_LOGO=0 -DRAM_TILES_COUNT=30 -DMAX_SPRITES=28
It's a really great game! Did you ever make a postmortem describing the way the scrolling and the camera system work with your level format, beyond what's in the source code?

User avatar
D3thAdd3r
Posts: 2422
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: New Game: Block Boy

Post by D3thAdd3r » Sun Mar 11, 2018 10:13 pm

Ah interesting, thanks for finding that and the fixes. I would not have expected that behavior, and I sense I probably have that same issue in several other games then. I should do 1 last sweep on the source for my older titles and implement that along with flash based streaming and call it finalized. Having more space is good, and then a bit more games using streaming music lending some "legitimacy".

So the way development worked out on that was good in the sense it got done quickly, but at the same time the pace was just full speed ahead so I did not really document things as I went. Something like Frog Feast I meant the whole game to be a tutorial...and failed at that main point :roll: To be honest, I would have to look at the source code myself to remember exactly how it worked. There is probably some use for a tutorial on that game specifically, even though it is certainly not the most complex scrolling scheme. I think the complexity is mostly based on what compression is being used(where it is only Meta Tile for BB), but the general concept there works even if there might be faster possibilities.

User avatar
Artcfox
Posts: 945
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: New Game: Block Boy

Post by Artcfox » Mon Mar 12, 2018 12:04 am

No problem! I just really would like to make a scrolling game for the UCC this year, and I figured I might be able to learn some tricks from Block Boy's scrolling/camera mechanism. Having more examples with flash-based streaming sounds awesome.

You did say that you started writing it as a way to teach yourself how the scrolling mode works, so the fact that it's not a particularly complicated scrolling mechanism seems like the perfect match for a tutorial. :)

One other thing that I would add to your Makefile would be

Code: Select all

-Wextra -Winline
after

Code: Select all

-Wall
I like -Winline, because I tend to inline a lot of things for speed, and I want to know when the compiler decides it's going to override my intention, so if need be, I can force it to be inlined by adding

Code: Select all

__attribute__((always_inline))
to the function's declaration.

I like -Wextra because it enables more warnings than -Wall, and I see that adding that option to Block Boy's Makefile gives one additional warning during the compile. And that's where things start to get interesting...

Enabling -Wextra for Block Boy gives the warning:

Code: Select all

../BlockBoy.c: In function ‘Intro’:
../BlockBoy.c:989:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(i+(j*10) >= sizeof(title_sine_table))
but looking at the code:

Code: Select all

	for(uint8_t i=0;i<180;i++){
		for(uint8_t j=0;j<6;j++){
			sprites[j].x = (j*8)+88;
			if(i+(j*10) >= sizeof(title_sine_table))
				sprites[j].y = 96;
			else
				sprites[j].y = pgm_read_byte(&title_sine_table[i+(j*10)]);
		}
		WaitVsync(1);
	}
you did use unsigned types! However C's implicit type promotion rules silently promoted your uint8_t types to a signed 16-bit int for the multiplication and addition operations, and what you're left with is a signed 16-bit int being compared to the unsigned result of sizeof(), hence the warning.

In this case, it seems to do no harm, and you can make that warning go away by forcing a cast

Code: Select all

if((uint8_t)(i+(j*10)) >= sizeof(title_sine_table))
but sometimes those silent implicit type promotions (especially when they change signedness) can cause real issues in your code, so it's especially nice to be warned by the compiler when the result could have unintended consequences.

The accepted answer to this stack overflow question is very thorough and will give you an idea of how nuanced the rules are, and the stack overflow question can give you an idea of how insidious not realizing when this is occurring can be.

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: New Game: Block Boy

Post by rocifier » Wed Mar 28, 2018 3:00 am

hi :) I tried to play this game, but I couldn't figure out the controls. How do I lift a block? Can you add an instructions page to the in-game menu?

User avatar
Artcfox
Posts: 945
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: New Game: Block Boy

Post by Artcfox » Wed Mar 28, 2018 3:31 am

rocifier wrote:
Wed Mar 28, 2018 3:00 am
hi :) I tried to play this game, but I couldn't figure out the controls. How do I lift a block? Can you add an instructions page to the in-game menu?
Each game has it's own wiki page: http://uzebox.org/wiki/Block_Boy

All the wiki pages: http://uzebox.org/wiki/Games_and_Demos

rocifier
Posts: 71
Joined: Thu Jan 22, 2015 6:35 am

Re: New Game: Block Boy

Post by rocifier » Wed Mar 28, 2018 4:43 am

Artcfox wrote:
Wed Mar 28, 2018 3:31 am
rocifier wrote:
Wed Mar 28, 2018 3:00 am
hi :) I tried to play this game, but I couldn't figure out the controls. How do I lift a block? Can you add an instructions page to the in-game menu?
Each game has it's own wiki page: http://uzebox.org/wiki/Block_Boy

All the wiki pages: http://uzebox.org/wiki/Games_and_Demos
Thanks!

User avatar
D3thAdd3r
Posts: 2422
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: New Game: Block Boy

Post by D3thAdd3r » Fri Mar 30, 2018 1:14 am

Ah yes, I did make a manual linked on the wiki pages for a few games but Block Boy there is basically nothing to write about past the controls. If/when I get back to Block Boy(Artcfox did track down some potential issues and fixes that I should apply), perhaps I will add the B button as a way to pick up blocks as well as an instructions option. A couple people I have showed it to were a bit surprised you push down to lift, so I should utilize target audience feedback to polish it up a bit.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest