Author Topic: Stars field layout  (Read 6193 times)

JMD

  • Newbie
  • *
  • Posts: 5
    • View Profile
Stars field layout
« on: December 07, 2014, 11:47:19 AM »
hello,

I am new to the forum and I would first say that I find really fantastic Attract mode. It was exactly what I wanted to put in my mamecab.

I took advantage of some free time this weekend to try to write a little Squirrel theme . Absolutely not knowing the language , I had some difficulties to start but I quickly got to do what I wanted .
I enclose an attachment and I 'm interested in your advice and comments , especially on my use of language and the squirrel Attract Mode API.

Thank you in advance .

JMD
AM Version : 1.5.3
Input : Cabinet (J-Pac); Mouse; Keyboard
Cabinet : Yes (15kz CRT Monitor)
OS : Windows7 x64
System : Intel E6670 ; 4Go RAM ; ATI HD4850 
Emulators : mame; gens; fs-uae

JMD

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Stars field layout
« Reply #1 on: December 08, 2014, 10:37:41 AM »
Hello,

I tried a bubble layout but I don't know how to force the marquee and snap to be upon the bubbles.
How can I do ?

Thanks !

JMD

Code: [Select]
//
// Attract-Mode Front-End - "Bubble" layout
//
 
class Bubble
{
    Bubblespng = ["1.png","2.png"];

    id=0;
img=null;
pos_x =0;
pos_y =0;
color =0;
speed = 5;

function init ( n  )
{
        id = n;
pos_x = (rand()*660/RAND_MAX)-16;
                pos_y = 500 + (rand()*35/RAND_MAX);
color = (rand()*2/RAND_MAX);
speed = (rand()*3/RAND_MAX)+1;
img = fe.add_image( Bubblespng[color], pos_x, pos_y );
}

function move()
{
    pos_y -= speed*0.3;
            if( pos_y <=-20 ) {
               pos_y = 500 + (rand()*35/RAND_MAX);
               pos_x = (rand()*640/RAND_MAX);
               speed = (rand()*5/RAND_MAX)+1;
            }
            img.x = pos_x;
            img.y = pos_y;
}
}

    // set front end resolution
    fe.layout.width=640;
    fe.layout.height=480;

    // add the game list box
    ::artwork_snap <- fe.add_artwork( "snap", 348, 120, 256, 262 );
    ::artwork_marquee <-fe.add_artwork( "marquee", 348, 16, 256 , 80 );

    local l = fe.add_listbox( 16, 16, 278, 460 );
    l.charsize = 20;
    l.set_selbg_rgb( 255, 255, 255 );
    l.set_rgb( 200, 200, 70 );
    l.set_sel_rgb( 0, 0, 0 );
    l.sel_style = Style.Bold;

    l = fe.add_text( "[ListEntry]/[ListSize]", 320, 442, 290, 17 );
    l.set_rgb( 200, 200, 70 );
    l.align = Align.Right;

    l = fe.add_text( "[Title]", 348, 408, 320, 17 );
    l.set_rgb( 200, 200, 70 );
    l.align = Align.Left;

    l = fe.add_text( "[Year] [Manufacturer]", 348, 425, 320, 17 );
    l.set_rgb( 200, 200, 70 );
    l.align = Align.Left;

    l = fe.add_text( "[Category]", 348, 442, 320, 17 );

    l.set_rgb( 200, 200, 70 );
    l.align = Align.Left;

    // add a "each frame" callback
    fe.add_ticks_callback( "tick" );
 
    ::Bubbles <- {};
    for ( local i=0; i<30; i++ ){
        // create new object
        ::Bubbles[i] <- Bubble();
        // init it
        ::Bubbles[i].init(i);
    }


function tick( ttime )
{
    for ( local i=0; i<30; i++ ){
        ::Bubbles[i].move();
    }

}

AM Version : 1.5.3
Input : Cabinet (J-Pac); Mouse; Keyboard
Cabinet : Yes (15kz CRT Monitor)
OS : Windows7 x64
System : Intel E6670 ; 4Go RAM ; ATI HD4850 
Emulators : mame; gens; fs-uae

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Stars field layout
« Reply #2 on: December 30, 2014, 10:58:09 PM »
Sorry I may misunderstand your question, but if you want your bubbles on the bubble layout to be drawn under the marquee and snap simply re-order your script so that the snap and marquee artworks are created at the end of the script (after the bubbles).

Attract-Mode always draws things in the same order that they are created in the script...

JMD

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Stars field layout
« Reply #3 on: January 03, 2015, 09:07:10 AM »
Hello,

I'm so stupid : it's works fine when I change order in the script.

Thanks a lot !


AM Version : 1.5.3
Input : Cabinet (J-Pac); Mouse; Keyboard
Cabinet : Yes (15kz CRT Monitor)
OS : Windows7 x64
System : Intel E6670 ; 4Go RAM ; ATI HD4850 
Emulators : mame; gens; fs-uae