Jump to content
IGNORED

Games in Mad Pascal


Recommended Posts

 

The ghost may have a little more AI

 

They have, but on higher levels of game ;)

 

You can check their behaviour in LevelEditor - here

 

There is a field : ghost AI - check different values.

On AI=9 ghosts are deadly ninjas.

Edited by bocianu
  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Hmm, I looked at the code of Graviten and there seems to be VERY compact and optimized way of moving object around. No additional if branches, just pure logic in one line using bitwise arithmetics. And using similar thing for rotating an object using offsets to an array of data.

 

Great work!

Edited by Gury
Link to comment
Share on other sites

Hmm, I looked at the code of Graviten and there seems to be VERY compact and optimized way of moving object around. No additional if branches, just pure logic in one line using bitwise arithmetics. And using similar thing for rotating an object using offsets to an array of data.

 

Great work!

Be very careful of one-liners in higher-level languages. Some translate to pages of ASM code...

 

The best way to produce fast code in higher-level language (say, C or Pascal), is to let the compiler produce also assembly file in parallel, and that way you can quickly compare your subroutine with the generated ASM code.

 

This will provide you with an insight that goes waaay beyond any benchmarks that you execute, since after a week or two of watching the generated ASM code, you'll be able to understand what works best (though the original code will never look like a human wrote it, but hey - it's fast so who cares :) ).

 

It will also be a source of major entertainment, as certain WTFs are truly mind blowing (talking about 68000 C compiler on jaguar here) :)

  • Like 2
Link to comment
Share on other sites

  • 8 months later...
  • 2 weeks later...
  • 1 month later...

 

program towers;
 
(* Towers:                          *)
(* A game written with CLSN Pascal  *)
 
(* Object:                          *)
(*   Move the six rings to another  *)
(*   peg.
 
(* Restrictions:                    *)
(*   1. Only one ring may be moved  *)
(*      at a time                   *)
(*   2. A larger ring may not be    *)
(*      placed on a smaller one     *)
 
(* Clue:
(*   The minimum number of moves    *)
(*   needed to complete the game    *)
(*   is 63.                         *)
 
uses crt;
 
const
  max_ring=6;
 
const
  ring_pic: array[0..max_ring] of string[15] =
            ('',
             '     -1-     ',
             '    --2--    ',
             '   ---3---   ',
             '  ----4----  ',
             ' -----5----- ',
             '------6------');
 
var
   post: array [0..3] of array[0..max_ring] of byte;
   quit: boolean;
  mvcnt: word;
 
procedure clear_line(y: byte);
begin
  gotoxy(1,y+1);
  ClrEol;
end;
 
function get_post: smallint;
var
  pn: byte;
 
begin
  repeat
    pn:=(ord(readkey) and $7F);
 
    quit:=(pn=27); pn:=pn-48;
 
  until {(pn in [1..3])} (pn=1) or (pn=2) or (pn=3) or quit;
 
  get_post:=pn;
end;
 
function top_ring_pos(pn: smallint): smallint;
var
  i: smallint;
 
begin
  i:=1;
 
  while (i<=max_ring) and (post[pn,i]=0) do
    inc(i);
 
  top_ring_pos:=i;
end;
 
procedure lift(pn,rf: smallint);
var
  tp: smallint;
 
begin
  tp:=top_ring_pos(pn);
 
  gotoxy(pred(pn)*13+1,13+tp);
  write('      |      ');
 
  gotoxy(pred(pn)*13+1,9);
  write(ring_pic[rf]);
end;
 
procedure drop(pn,rf: smallint);
var
  tp: smallint;
 
begin
  tp:=top_ring_pos(pn);
 
  clear_line(;
 
  gotoxy(pred(pn)*13+1,12+tp);
  write(ring_pic[rf]);
end;
 
procedure end_game;
var
   i: byte;
  ch: char;
 
begin
  for i:=2 to 22 do
    clear_line(i);
 
  gotoxy(13, ; write('CONGRATULATIONS');
  gotoxy(12,10); write('You completed the');
  gotoxy(12,11); write('game in ',mvcnt,' moves.');
 
  ch:=readkey;
end;
 
function win: boolean;
begin
  win:=(top_ring_pos(2)=1) or
       (top_ring_pos(3)=1);
end;
 
procedure make_move;
var
    pf,pt: smallint;
    rf,rt: smallint;
  tpf,tpt: smallint;
       ok: boolean;
 
begin
  clear_line(3);
 
  repeat
    gotoxy(3,4); write('Move top ring of what post: ');
 
    pf:=get_post;
 
    if quit then
      exit;
 
    write('''',pf);
 
    clear_line(4);
 
    tpf:=top_ring_pos(pf); rf:=post[pf,tpf];
 
    ok:=(tpf<=max_ring);
 
    if not ok then
      begin
        gotoxy(3,5);
        write('There are no rings there.');
      end;
 
  until ok;
 
  lift(pf,rf); post[pf,tpf]:=0;
 
  clear_line(3);
 
  repeat
    gotoxy(3,4); write('Move Ring #',rf,' to what post: ');
 
    pt:=get_post;
 
    if quit then
      exit;
 
    write('''',pt);
 
    clear_line(4);
 
    tpt:=top_ring_pos(pt); rt:=post[pt,tpt];
 
    ok:=(rf<rt) or (tpt>max_ring);
 
    if not ok then
      begin
        gotoxy(3,5);
        write('That move is invalid');
      end;
 
  until ok;
 
  drop(pt,rf); post[pt,tpt-1]:=rf;
 
  if (pf<>pt) then
    inc(mvcnt);
end;
 
procedure init_post;
var
  i,j: byte;
 
begin
  for i:=1 to 3 do
    for j:=1 to max_ring do
      case i of
        2,3: post[i,j]:=0;
          1: post[i,j]:=j;
      end;
end;
 
procedure init_screen;
var
  i,j: smallint;
 
begin
  clrscr;
 
  gotoxy(1,1); write(StringOfChar('-',40));
 
  gotoxy(13,1); write(' The Six Rings ');
 
  for i:=1 to 3 do
    begin
      gotoxy(pred(i)*13+7,7);
      write(i);
    end;
 
  for i:=1 to 3 do
    for j:=0 to max_ring do
      if (i=1) and (j<>0) then
        begin
          gotoxy(pred(i)*13+1,13+j);
          write(ring_pic[j]);
        end
      else
        begin
          gotoxy(pred(i)*13+7,13+j);
          write('|');
        end;
 
  gotoxy(1,20);
  write('______|____________|____________|______');
end;
 
begin
 
  init_post;
  init_screen;
 
  mvcnt:=0; quit:=false;
 
  repeat
    gotoxy(16,22); write('Moves: ',mvcnt);
    make_move;
  until win or quit;
 
  if win then
    end_game;
 
end.

mp156_example.zip

post-4486-0-82601200-1531548006.png

Edited by tebe
  • Like 2
Link to comment
Share on other sites

  • 6 months later...

Hello!

 

Here comes my another simple game written in Mad Pascal.

This game is entry for 6502 compo, and it has only 6476 bytes!

 

Sources as usual available at: https://gitlab.com/bocianu/hoppe

 

Enjoy!

 

I've played this for the last hour non-stop. This is a fantastic game! I hope you develop this further.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
  • 7 months later...

Here is another simple ZX Spectrum game port from the book Mirko tipka na radirko published by Moj Mikro magazine. This game is called Defense in which you have defend planet Earth from alien invasion.

 

defence01.png.948cae98dc4edc04d991d383be932952.png defence02.png.0aa6d213d3d28af5c06c140a3fe2082a.png

 

defence.xex defence.pas

 

Included with the game is new version of ZXLib unit, which features BEEP procedure, which simulates Sinclair BASIC BEEP procedure. It produces sound in middle C notes. It is not perfect yet, but it basically works. Pitch selection above 0 is quite ok, with lower pitches not yet balanced very well yet. But anyway, here is little example of using it: doremi.xex doremi.pas

 

Attached below are all files together in zip file.

 

Original source:

Link 1

Link 2

zxlib.pas defence.zip

Link to comment
Share on other sites

Another game from the book Mirko tipka na radirko, called Moj Mikro Asteroids.

 

mmaster01.png.6753480e65118f04af679ddccaa65e14.png mmaster02.png.268e40549f1b4dc2dbe120ec3b10f49a.png

 

I called this game such because I didn't want to make any confusion with the classic Atari game Asteroids.

When started your ship is head to head with the asteroids, which are moving from the bottom of the screen to the top. You must avoid them, of course, and you have five lives before game ends. You have five shields you can use throughout the game to save your life when colliding with an asteroid.

 

mmaster03.png.748425a33cc9419a36e09aa90535002b.png mmaster04.png.aea2094e10b2397110adfd8e123bcc28.png

 

Original source:

Link 1

Link 2

 

Side note:

The ship is waving because of the way fine vertical scrolling is implemented.

 

Enjoy!

 

mmaster.zip mmaster.xex mmaster.pas

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Here is another game called Mouse Mervin originally programmed by Marko Jerič for ZX Spectrum in Sinclair BASIC.

 

You control mouse Mervin, who tries to eat all cheese from the moon. To reach this goal he must use a ship which has enough rockets with fuel to launch him to the stars. You move ship left and right with the joystick to help Mervin to eat as many cheese as he can. There are two levels of gameplay, Mervin has 5 lives and to progress to the next set of cheese you must eat nearly all of them. On the third screen there is also a twist :)

Arkanoid style game...

 

mouse_mervin.png.c0b9ad2f945fd2468c3d583504816b2e.png mouse_mervin_1.png.ac8e76f0fdc0806ab323a1336c40da06.png

 

Reference:

Link 1

Link 2

Link 3

 

mouse_mervin.zip mervin.xex

Edited by Gury
Some text amendments
  • Like 2
Link to comment
Share on other sites

Hello!

 

I've prepared another little game here.

 

oldmansion.png.4da571203a2a6f0e21adc20ef1f36452.png    oldmansion2.png.a9a0f280936d0dcbf40a5fab38a8514c.png

 

This game was originaly written in BASIC by Wojciech Zientara, and published in Polish computer magazine "Bajtek" in 1987.

I've translated this game to Mad-Pascal, fixed some bugs, changed balance and difficulty a little bit, and added some simple graphics and music.

 

You can turn off (and on) music using SELECT button.


All sources (Basic too) are available here: https://gitlab.com/bocianu/oldmansion

 

I hope you will enjoy it. 

 

 

EDIT: quick fix added, there was a left margin problem ;) 

 

 

oldmansion.xex

Edited by bocianu
  • Like 3
Link to comment
Share on other sites

  • 8 months later...
  • 1 year later...
  • 2 weeks later...
  • 1 month later...

I'm trying to finish a modest rogue like game on Silly Venture https://www.sillyventure.eu/en/ as a A8 game compo filler ;)

 

Maybe someone has spare music? If so, please PM me.

 

If nobody has anything spare  I will release game without music :D

 

thx in advance :]


ps. fire generates next map, teaser of the game after a few moments of coding

main.xex

Edited by zbyti
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...