Game geeks will love it

Here is an implementation of the popular "Lines" Russian game written by Alexei Mokeev in F3. Business logic and cool graphics in less than 350 lines of code. Take a look at the snippet below to see how one leverages Java the language, and of course this runs on the JVM.

 

import f3.ui.\*;
import f3.ui.canvas.\*;
import java.lang.System;
import java.lang.Math;

 ...

operation Lines.moveBallTo (to:LinesCell) {
    var path:LinesCell\* = [to];
    while(to.marker <> 0) {
       to = getMinimumAround(to);
       insert to as first into path;
    } //OK. We have Path

    activeCell =-1;
    var frm:LinesCell = path[0];
    to = path[sizeof path -1];

    var l:Integer = sizeof path;

    if (l == 2) {
        to.ballColor = frm.ballColor;
        frm.busy = false;
        to.busy = true;
        changed = true;
        dropBalls();
        return;
    }

    // Clearing FROM
    to.ballColor = frm.ballColor;
    frm.busy = false;

    for (cell in path[indexof . <l-1]) (dur (l-2)\*100 linear) {
        cell.marker = -10; //Field in movement
    }

    for (cell in path[indexof . < l]) (dur (l-2)\*200 linear) {
        cell.marker = -1; //Stop markup
        if ((cell.x == to.x) and (cell.y == to.y)) { //Ok. We at the end
            to.busy = true;
                   
            for (c in fld[n|n.marker == -10]) { c.marker = -1;}
            changed = true;
            dropBalls();
        }
    }

}
 

Take a look at the screen shot of the game running on my Mac.

 

Comments:

Hi dude, I got java.net.UnknownHostException: jseqe.sfbay.sun.com when downloading the app. Can you put it somewhere out please. Cheers

Posted by Vojtech on April 09, 2007 at 02:56 AM PDT #

Will do, I linked by accident the internal deployment.

Posted by guest on April 09, 2007 at 12:31 PM PDT #

import f3.ui.\*; import f3.ui.canvas.\*; import java.lang.System; import java.lang.Math; ... operation Lines.moveBallTo (to:LinesCell) { var path:LinesCell\* = [to]; while(to.marker <> 0) { to = getMinimumAround(to); insert to as first into path; } //OK. We have Path activeCell =-1; var frm:LinesCell = path[0]; to = path[sizeof path -1]; var l:Integer = sizeof path; if (l == 2) { to.ballColor = frm.ballColor; frm.busy = false; to.busy = true; changed = true; dropBalls(); return; } // Clearing FROM to.ballColor = frm.ballColor; frm.busy = false; for (cell in path[indexof . <l-1]) (dur (l-2)\*100 linear) { cell.marker = -10; //Field in movement } for (cell in path[indexof . < l]) (dur (l-2)\*200 linear) { cell.marker = -1; //Stop markup if ((cell.x == to.x) and (cell.y == to.y)) { //Ok. We at the end to.busy = true; for (c in fld[n|n.marker == -10]) { c.marker = -1;} changed = true; dropBalls(); } } }

Posted by guest on May 09, 2007 at 03:54 PM PDT #

Thanks for posting it here

Posted by guest on May 15, 2007 at 01:39 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

octav

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today