#18840 - s00p - Wed Apr 07, 2004 12:00 am
oo it's playable now :D
You don't advance to the next level yet, but you can trap the aliens in boxes and die if they hit your line or you go back over it.
updated: http://www.skateflint.com/fillit.gba
Original java game I'm trying to recreate:
http://www.skateflint.com/fill-it.html
Done:
Player sprite that follows your cursor and draws lines
Randomly generate alien sprites
Collision of the aliens with the pink line you draw
Collision when you hit your pink line
Die script
Display lives / level onscreen.
Aliens bounce off any blue lines (corners are buggy)
To do:
Fix palettes (aliens use the ship palette)
Fill boxes and display percent filled onscreen.
Last edited by s00p on Thu Apr 08, 2004 11:50 pm; edited 9 times in total
#18844 - dagamer34 - Wed Apr 07, 2004 12:33 am
That's really nice. Keep up the good work.
_________________
Little kids and Playstation 2's don't mix. :(
#18866 - Lupin - Wed Apr 07, 2004 12:32 pm
Good work! I played it five minutes with speed toggle activated and that's the result: http://home.arcor.de/lupin003/blah.gif
You seem to move the cursor by 6 pixels :)
For collision detection i would just check the pixels on the buffer.
_________________
Team Pokeme
My blog and PM ASM tutorials
#18890 - s00p - Wed Apr 07, 2004 7:53 pm
Lupin wrote: |
Good work! I played it five minutes with speed toggle activated and that's the result: http://home.arcor.de/lupin003/blah.gif
You seem to move the cursor by 6 pixels :)
For collision detection i would just check the pixels on the buffer. |
yeah I did that too, on normal speed. I set it to move the cursor by that much so I can split the board into squares, the plan was/is to make it easier to do collision by splitting the playing field into a grid. Checking the pixels in the buffer would be useful, so I could detect whether an alien touched the line, (any pink pixels only) can you go into more detail on how I would do that?
#18891 - Lupin - Wed Apr 07, 2004 8:12 pm
Well, it's kinda easy. You just have to check the current pixel the monster is at and check if it is pink (but you can only move your monsters by 1 because you'd skip pixels if you move more). The tricky part is to change the velocity of your monster but you already do that on the boarder of your game-map (you just have to find out if the pixel you colided with is part of an horizontal or vertical wall).
I have tried to write the same thing now, but i am currently thinking about how to fill the areas...
_________________
Team Pokeme
My blog and PM ASM tutorials
#18894 - s00p - Wed Apr 07, 2004 8:25 pm
Actually:
Code: |
if (vbl_count > 3){
query_buttons();
vbl_count = 0;
}
void query_buttons()
{
int c;
for(c=0;c<6;c++){ |
it moves the cursor 6 spaces every 3 vbl's, so having the aliens skip over them is not an issue because I would use the same method for those.
ok I have collision working with the aliens.. so easy!
#18897 - s00p - Wed Apr 07, 2004 9:22 pm
It would be pretty easy to make the boxes if I could check the color of every pixel quickly.
ie Code: |
if (videoBuffer[posy * 240 + posx] == blue){
for(x=0;x<240;x++){
for(y=0;y<160;y++){
if (videoBuffer[y * 240 + x] == pink){
videoBuffer[y * 240 + x] = blue;
}
}
}
} |
but this is way too slow, so that wouldn't work.
ship animation is done.
Collision with your own line is done.
#18902 - dagamer34 - Wed Apr 07, 2004 11:08 pm
One thing, you are able to move the cursor before you officially start the game. Try moving it around without pressing start. Or is that supposed to happen?
_________________
Little kids and Playstation 2's don't mix. :(
#18904 - s00p - Wed Apr 07, 2004 11:21 pm
hah, I knew about that but I forgot to fix it. It's fixed now.
#18975 - tepples - Fri Apr 09, 2004 12:57 am
s00p wrote: |
Collision when you hit your pink line |
The way that's implemented in the Java applet is annoying. Play Taito's original Qix for Game Boy to see how to do it right: 1. Ignore presses that directly oppose the cursor's current direction (the Java applet has killed me several times when I've held left then quickly pushed up right, ignoring the up press), and 2. Kill cursor only when it has started a spiral. In addition, Qix seems to move the enemy a bit slower when it's inside a smaller box.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#18976 - s00p - Fri Apr 09, 2004 2:21 am
Ok I fixed that. It annoyed me too!
Can anyone think of a good way to fill in the boxes? I have it log your path as you draw it, so maybe I could use values from that and then loop it to fll in each pixel from there to the path value on the other side, or is there a better way? Also, how do I load two seperate palettes (or combine them into one)? Because the aliens are using the ship's palette right now..
#18984 - tepples - Fri Apr 09, 2004 4:18 am
s00p wrote: |
Can anyone think of a good way to fill in the boxes? I have it log your path as you draw it |
In Qix and its clones, a polygon is guaranteed not complex because you can't run into your own line. So you need only consider scan-converting potentially concave polygons. Find the boundaries of the potentially concave polygon that the path makes with the surroundings. In general, you set a pixel at (x, y) iff a line from (-Inf, y) to (x, y) crosses an odd number of edges. Sort edges by starting Y location. Scan from left to right across the polygon; if you hit a vertical edge, start drawing, and if you hit another vertical edge, stop drawing.
Here's an explanation of polygon filling.
Quote: |
Also, how do I load two seperate palettes (or combine them into one)? Because the aliens are using the ship's palette right now.. |
First of all, you should be using 16-color graphics. Then to load the palettes, just load them at different indices into palette memory (e.g. PALRAM[256..271] and PALRAM[272..287], and set the colors in each sprite's attribute 2.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#18991 - Lupin - Fri Apr 09, 2004 2:15 pm
i tried to do as you said, but it's more than just scanning each scanline. Look at my 1337 illustration of my problem: http://home.arcor.de/lupin003/blah.gif
As you see this is badly drawn, but you also see that the blue lines represent the very left extent on the X axis (i have an array that saves the extent of my line to left/right on each scanline). But the extent to the left is in wrong place because it should be at the boarder of the image. The light blue line represents the extent how it should be.
For this case i could just start scanning each scanline from x=0, but i wouldn't take the bottom part of the polygon into account.
I hope you got what i mean... it's driving me nuts that i am not able to implement something that simple! :/
_________________
Team Pokeme
My blog and PM ASM tutorials
#18992 - tepples - Fri Apr 09, 2004 2:51 pm
Right. You have to determine a second path from the start of the drawn path to the end of the drawn path along the edge of the player's claim or the edge of the screen. Thus, most of your black line would be within this second path. To do this, you may have to log the border of the player's claim as a concave polygon as well.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#18993 - s00p - Fri Apr 09, 2004 3:06 pm
tepples wrote: |
First of all, you should be using 16-color graphics. Then to load the palettes, just load them at different indices into palette memory (e.g. PALRAM[256..271] and PALRAM[272..287], and set the colors in each sprite's attribute 2. |
Can you elaberate? I don't know how to use the sprite attributes, or set them up.
#18994 - tepples - Fri Apr 09, 2004 3:40 pm
Please read the following sections of the CowBite spec:
http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Palette
http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm#Attribute%202
and then tell us what you fail to understand.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#18995 - s00p - Fri Apr 09, 2004 3:54 pm
I don't know how you set it up so you can do sprite.attribute2 = ?. Is there a header I should get that has the definitions or whatever?
http://www.thepernproject.com/English/tutorial_3.html reading..
meh, I got it to work but didn't use the attribute value. Just combined the palettes and that worked.
#18996 - tepples - Fri Apr 09, 2004 4:11 pm
How are you setting the tile number for the existing sprites? The palette number is the upper four bits of that.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#18997 - s00p - Fri Apr 09, 2004 5:02 pm
Code: |
#define ANIM_UP 0
#define ANIM_RIGHT 1
#define ANIM_DOWN 2
#define ANIM_LEFT 3
---
ham_LoadObjPal((void*)master_Palette, 256);
ship = ham_CreateObj((void*)ship_Bitmap,OBJ_SIZE_8X8,OBJ_MODE_NORMAL,1,0,0,0,0,0,0,116,154);
ham_CopyObjToOAM();
---
ham_UpdateObjGfx(ship,(void*)&ship_Bitmap[64*dir_ship]);
|
#19016 - tepples - Sat Apr 10, 2004 2:49 am
I don't use HAMlib. You'll need to look at the HAMlib manual to learn how to set a sprite's palette.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#19018 - s00p - Sat Apr 10, 2004 3:30 am
tepples wrote: |
I don't use HAMlib. You'll need to look at the HAMlib manual to learn how to set a sprite's palette. |
I said I got it to work.
#19110 - Lupin - Sun Apr 11, 2004 1:55 pm
the filling is impossible... i tried a lot, but it simply doesn't work.
_________________
Team Pokeme
My blog and PM ASM tutorials
#19140 - s00p - Sun Apr 11, 2004 10:40 pm
Well what did you try? If I spent a little bit more time on this I'd have it filling simple boxes, so I'm sure it's possible.
#19148 - Lupin - Mon Apr 12, 2004 1:49 am
well, it is possible, just not by using the scanline method. You have to use a floodfill algo on a low resolution version of the map (you can call this something like a BSP map). This way you will also be able to check on what side the enemy is or what side is larger. I am going to implement it like this, i just need to find an fast floodfill algo :/
The problem with the scanline method is that...
-you can not clearly specify the actual parts of your rectangular shape because the walls are a part of it, but not all walls (therefor you have to render it in 2 parts as tepples answered to my question)
-you have to take care of vertical lines (only horizontal lines can make drawing stop/start)
Actually it sounds quite simple but i was not able to get it work :(
_________________
Team Pokeme
My blog and PM ASM tutorials
#19152 - s00p - Mon Apr 12, 2004 4:14 am
#24794 - gotenks06 - Wed Aug 11, 2004 5:34 pm
s00p wrote: |
I don't know how you set it up so you can do sprite.attribute2 = ?. Is there a header I should get that has the definitions or whatever?
http://www.thepernproject.com/English/tutorial_3.html reading..
meh, I got it to work but didn't use the attribute value. Just combined the palettes and that worked. |
Make sure to #include "sprite.h" and use the OAMEntry struct. After you have set it up, DMA transfer it to OAM with count set to 16 | DMA_ENABLE.