Results 1 to 9 of 9

Thread: Mobile Puzzle Game

  1. #1

    Mobile Puzzle Game

    This is my first MIDLet game.
    It's just a simple puzzle game.
    mobilepuzzlegame.rar - 0.00MB



    [pascal]
    program EnkoFirstGame;

    const
    NUM = 16; //la mA¬°xima cantidad de numeros
    ADD = 13; //desplazamiento para la salida de los numeros

    var
    board: array[1..4, 1..4] of integer; //nuestro tabla
    x,y: integer; //variables que guardan la posicion del espacio vacio
    key: integer; //la tecla presionada
    gameOver: boolean; //indicarA-a si el juego sigue


    //llena la tabla con numeros ordenados del 1 al 16
    //algo asA- (el 16 es el espacio vacio):
    { 1 2 3 4
    5 6 7 8
    9 10 11 12
    13 14 15 16
    }
    procedure setBoard;
    var
    i,j,k: integer;
    begin
    k:=1;
    for j:=1 to 4 do
    for i:=1 to 4 do
    begin
    board[i,j] := k;
    k := k+1;
    end;
    end;

    //intercambia los numeros de las tablas segun sus indices
    procedure swap(a,b,c,d: integer);
    var
    k: integer;
    begin
    k := board[a,b];
    board[a,b] := board[c,d];
    board[c,d] := k;
    end;

    //asigna la posicion del espacio vacio
    procedure setPos(a,b:integer);
    begin
    x:=a;
    y:=b;
    end;

    //imprime en la pantalla los numeros menos el 16
    procedure printBoard;
    var
    s: string;
    i,j: integer;
    begin
    //ponemos negro como color activo
    setColor(0,0,0);
    //lenamos la pantalla con el color activo
    //GetWidth y GetHeight son funciones predeterminadas
    fillRect(0,0, GetWidth, GetHeight); //devuelven el Ancho y Alto maximo
    //elegimos el color blanco
    setColor(255,255,255);
    for j:=1 to 4 do
    for i:=1 to 4 do
    begin
    //como solo se puede imprimir cadenas, transormamos los numeros en cadenas
    s:= IntegerToString(board[i,j]);
    // si el nuemro no es 16, se imprime segun la posicion en la tabla
    if s<>'16' then drawText(s, ADD+i*18, j*1;
    end;
    //indispensable, actualiza la pantalla del mobile.
    repaint;
    end;

    procedure Presentation;
    var
    key: integer;
    begin
    setColor(0,0,0);
    fillRect(0,0, GetWidth, GetHeight);
    setColor(255,0,0);
    drawText('Enkos Puzzle', 20,20);
    drawText('Loading', 20,40);
    repaint;
    delay(2000);
    end;

    procedure Ending;
    var
    key: integer;
    begin
    setColor(0,0,0);
    fillRect(0,0, GetWidth, GetHeight);
    setColor(255,0,0);
    drawText('Enkos Puzzle', 20,20);
    drawText('Good Buy',20,40);
    repaint;
    delay(2000);
    end;


    //buscamos en la tabla la posicion del espacio vacio
    //la verdad, es que hay formas de evitar hacer esto
    //pero como que tenia un BUG y tuve que hacerlo
    procedure getPos;
    var
    i,j: integer;
    begin
    for i:=1 to 4 do
    for j:=1 to 4 do
    begin
    if board[i,j] = 16 then
    begin
    x := i;
    y :=j;
    end;
    end;
    end;

    //incercambia las posiciones de los numeros
    //para que despues el jugador los tenga que ordenar
    procedure randomBoard;
    var
    i,j,i1,j1,k: integer;
    begin
    randomize;
    for i:=1 to 4 do
    for j:=1 to 4 do
    begin
    i1:= random(4)+1;
    j1:= random(4)+1;
    swap(i,j,i1,j1);
    end;
    getPos; //obtenemos la posicion del espacio vacio
    printBoard;//imprimimos la tabla
    end;

    //procedimiento que realiza el desplazamiento del espacio vacio
    //b nos indica la direccion, 1: Arriba, 2eracha, 3:Abajo, 4:Izquierda
    //segun el caso, no podemos desplazar el espacio vacio afuera del tablero, por eso
    //esta la condicion adicional si es mayor o menor a 4 o a 1.
    procedure moveBoard(b:integer);
    begin
    if (b=1) and (y<4)then swap(x,y,x,y+1)
    else if (b=2) and (x>1) then swap(x,y,x-1,y)
    else if (b=3) and (y>1) then swap(x,y,x,y-1)
    else if (b=4) and (x<4) then swap(x,y,x+1,y);
    delay(200); //retrazamos la jugada siguiente, porque sino, se mueven muy rapido
    getPos;
    printBoard;
    end;

    // el programa en si
    begin
    Presentation; //mostramos la presentacion
    setBoard; //iniciamos el tablero
    randomBoard; //lo mezclamos
    repeat //el ciclo del juego
    key := getKeyPressed; // obtenemos la pulsacion
    if (key = KE_KEY2) or (KeyToAction(key) = GA_UP) then moveBoard(1);
    if (key = KE_KEY6) or (KeyToAction(key) = GA_RIGHT) then moveBoard(2);
    if (key = KE_KEY or (KeyToAction(key) = GA_DOWN) then moveBoard(3);
    if (key = KE_KEY4) or (KeyToAction(key) = GA_LEFT) then moveBoard(4);
    until (key = KE_KEY0) ; //se juega hasta quese presiona 0
    Ending; //la pantalla de despedida
    end.
    [/pascal]

  2. #2

  3. #3
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Mobile Puzzle Game

    Send me your JAR and I'll load it to my web site for people to access.

    William (AT) Cairnsgames dot co dot za
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  4. #4

    Mobile Puzzle Game

    Quote Originally Posted by cairnswm
    Send me your JAR and I'll load it to my web site for people to access.

    William (AT) Cairnsgames dot co dot za
    Thanks a lot, how can I send it?

    PD: you can download it from ZShare, I had linked it alredy.

  5. #5

    Mobile Puzzle Game

    Nice colours!
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #6

    Mobile Puzzle Game

    Quote Originally Posted by savage
    Nice colours!
    I tried to found images in google, then selected 5 of them and put them in 96x96 resolution for the game. Finally select de best for this resolution. But >I think it was more easy with numbers, but who cares, it can be anything...

  7. #7
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    Mobile Puzzle Game

    I tried to download it and just got file not found errors - thats why I suggested emailing it to me.

    I will be building a mobile section to my web site soon. If anyone else wants games up there let me know - Email to me along with a little image of the game and some background - like a description, your name/alias etc - and I'll load them.

    This will be just for mobile games - and file sizes less than 65K each.
    William Cairns
    My Games: http://www.cairnsgames.co.za (Currently very inactive)
    MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)

  8. #8

    Mobile Puzzle Game

    Excelent. I will try to add some sound to the game and then, when your Mobile section will be working, I will send it.

  9. #9

    Mobile Puzzle Game

    Ok my first game on MidletPascal............... is almost complete, I uploaded but I make some changes on it so give me time ok




    Ok here`s my Midlet Game................well is not a game realy is.... just judge by your self.
    Thanks

    Download jad>>> http://www.zshare.net/download/ball-jad-e6v.html

    Download jar>>>http://www.zshare.net/download/ball-jar-nk0.html

    The hell is empty, all the devils are here.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •