Message Board


Message Board > Fenix / Bennu / Gemix / DIV > question on collisions and fullscreen_palette troubles

December 16, 2006, 16:23
Nikki
Whiskered
15 posts
Hi there, i've worked a little bit with DIV, and i recently discovered all of you.....

I have just set up flamebird, and the fenixpack,
but i've got 2 little problems.

1) when i put my application to full_screen the palette goes funky. windowed is ok.

2) i am trying to make a few buttons without the gui.dll and they are working but they don't feel very fast
(sometimes you have to click a few times for a button to change state)

My Code

PROGRAM muisje;
GLOBAL
file1;
BEGIN
    Graph_mode = mode_8bits;
    full_screen = 1;
    file1 = LOAD_FPG("muis.fpg");
    SET_MODE(m320x240);
    mouse.graph=2;

knop(100,100,3);
knop(150,150,3);
knop(200,200,3);
LOOP
    x=mouse.x;
    y=mouse.y;
    WRITE (0,150,150,0,x);
    WRITE (0,175,150,0,"X positie");
    WRITE (0,150,160,0,y);
    WRITE (0,175,160,0,"Y positie");
FRAME;
DELETE_TEXT(0);
END
END
//-------------------------------------------------------
PROCESS knop(x,y,graph);
PRIVATE
flag=0;
BEGIN
LOOP
FRAME;

IF (mouse.left AND COLLISION (TYPE mouse) AND graph == 3 AND flag==0)
    graph=4;
    flag=1;
END
IF (mouse.left AND COLLISION (TYPE mouse) AND graph == 4 AND flag==1)
    graph=3;
    flag=0;
END

END
END
//--------------------------------------------------------


Could someone advise me??
____________
#
December 16, 2006, 17:13
Rincewind
programmer
1546 posts

Hello Nikki, welcome to Boolean Soup. :)

Problem 1

It might have to do with the order you are setting things.

Right now you have:
Code:
Graph_mode = mode_8bits; 
full_screen = 1; 
file1 = LOAD_FPG("muis.fpg"); 
SET_MODE(m320x240); 

'

As I have learned it, you must always set the window to full screen first before you set the resolution and possibly the color mode. As you're setting the window to full_screen after selecting the color mode this might be the problem, but it is just a guess. Fenix has an improved set_mode() compared to div, so if you would please try changing the above code to:

Code:
Full_screen = 1; 
Set_mode(320,240,8);

File1=load_fpg("muis.fpg");

'

If this doesn't fix your problem it could either be a problem with your fpg or with your video card.

Something else, a bit unrelated, but instead of this:
Code:
LOOP 
    x=mouse.x; 
    y=mouse.y; 
    WRITE (0,150,150,0,x); 
    WRITE (0,175,150,0,"X positie"); 
    WRITE (0,150,160,0,y); 
    WRITE (0,175,160,0,"Y positie"); 
FRAME; 
DELETE_TEXT(0); 
END 

'

You can use the command write_int(), which writes an integer and automatically updates the value. So the above piece of code would become:

Code:
 
Write_int(0,150,150,0,offset mouse.x);
Write(0,175,150,0,"X positie");

Write_int(0,150,160,0,offset mouse.y);
Write(0,175,160,0,"y positie");

Loop
    Frame;
End

'

Please note that the writing commands are placed outside the loop now.


Problem 2

Code:
PROCESS knop(x,y,graph); 
PRIVATE 
flag=0; 
BEGIN 
LOOP 
FRAME; 

IF (mouse.left AND COLLISION (TYPE mouse) AND graph == 3 AND flag==0) 
    graph=4; 
    flag=1; 
END 
IF (mouse.left AND COLLISION (TYPE mouse) AND graph == 4 AND flag==1) 
    graph=3; 
    flag=0; 
END 

END 
END 

'

The problem here is, that if flag is zero, and it gets set to 1, it after that runs into your second if statement, which will also be executed because flag has been set to 1 by the earlier if statement. So basically both IF statements are executed which results in weird behaviour. Another problem is that the button will flash between the two states because a mouse click will most likely not last a single frame. This can be fixed by using a buffer (in the example down here I use the variable Pressed), so you'll first have to release the mouse button before you can click the button again.

Also, putting the frame command all down in your loop would be good practise.

Tidy up:

Code:
Process knop(x,y,graph);
Private
    Flag=0;
    Pressed=0;
Begin
    File=file1;

    Loop
        If (mouse.left and collision(type mouse) and Pressed==0)
            If (flag==0)
                flag=1;
                graph=4;
            Else
                flag=0;
                graph=3;
            End
            Pressed=1;
        End

        If (not mouse.left and Pressed==1)
            Pressed=0;
        End

        Frame;
    End
End

'

Optionally you probably want to increase the framerate, which by standard I thought is 25, which is a little low. You can always set the framerate with set_fps(frames per second, frameskip). So for example you could place set_fps(70,0) on the line below your set_mode().

Also, it seems you are Dutch. :thumbs:

Edit: The code of problem 2 has been editted again, forgot something.

[Edited on December 16, 2006 by Rincewind]
____________
Personal website: http://www.loijson.com
#
December 16, 2006, 20:38
Nikki
Whiskered
15 posts
thanks man,
at first i tried your original post (cntrl-v)
and it didn't work,

i was messing about unsuccesfully, until i read your edited post.
Thank alot man,

I am going to get my original div thingies and try em out.

This is brilliant,
and yes i am dutch. :P


btw, the fullscreen colors keep on getting stranger everytime.
its bizarre ...
when i restart flamingbird it changes the colours pretty random everytimen.

but only when in fullscreen-mode

maybe

[Edited on December 16, 2006 by Nikki]
____________
#
December 16, 2006, 20:57
Rincewind
programmer
1546 posts

Glad you got the button working!

Quote:
at first i tried your original post (cntrl-v)
and it didn't work,
Yeah sorry for that, I had forgotten something. :F

Quoting Nikki:
btw, the fullscreen colors keep on getting stranger everytime.
its bizarre ...
when i restart flamingbird it changes the colours pretty random everytimen.

but only when in fullscreen-mode

maybe


Are you sure the fpg is 8 bit? Perhaps you could upload your fpg+prg somewhere so I can check if the colors also mess up here. If it doesn't mess up for me, it might well be a video card issue. And IF it is a video card issue, using a high resolution might just fix it.
____________
Personal website: http://www.loijson.com
#
December 16, 2006, 21:16
Nikki
Whiskered
15 posts
http://www.filefactory.com/dlf … 108b3036a16827c

http://www.filefactory.com/dlf … 7f12fdc882beeff


thanks man, this feels like real help...
didn't expect this. :praise:

edit first file = prg
second file fpg



second edit > A high resolution did the trick.
so no nice 320 240 resolution then...?

[Edited on December 16, 2006 by Nikki]
____________
#
December 16, 2006, 21:38
Rincewind
programmer
1546 posts

The colors work well for me in 320*240 when full screen. And since a higher resolution does work fine for you, it is a video card issue. Your video card just doesn't support such a low resolution with 8 bit colors. To still use 320*240, you can use a 16 bit fpg and the 16 bit graphics mode in Fenix. Your graphics card most likely WILL support that.

And if that doesn't work, you can also use 640*480 with scale2x, a set_mode() flag (an optional fourth parameter) that basically doubles the sprites size and makes the pixels all smooth) to nicely scale up smaller graphics.


At last a small comment on your "filled" graphic: It has a lot of transpant holes in it, so when checking for a collision and when you have your mouse on a transparant pixel, the collision won't be detected (and the box won't be emptied) because there is none. So perhaps fill the holes with a color.

[Edited on December 16, 2006 by Rincewind]
____________
Personal website: http://www.loijson.com
#
December 17, 2006, 00:49
Nikki
Whiskered
15 posts
It's all working like a charm now.

thanks man.
____________
#

Message Board > Fenix / Bennu / Gemix / DIV > question on collisions and fullscreen_palette troubles

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!