Recent

Author Topic: CentiPeed clone, almost finished (video)  (Read 403 times)

TBMan

  • Sr. Member
  • ****
  • Posts: 335
CentiPeed clone, almost finished (video)
« on: April 12, 2025, 05:36:50 am »
Here's a short video of a Centipeed clone that I'm almost finished with. I had started this a while ago, first with Borland Pascal running in DOSBOX and then I tweaked it in Larzarus. I had stopped working on it because I was getting too much flickering from the centipeed rendering, but I redid the animation process using page flipping and now it's much better. Yesterday I added the flea and today I added the spider. I have both dropping into gameplay after 100 points just for debugging purposes (no pun intended  :D  ).  I have to do some more research on the triggers for both of these and then see what other critters should be added to the game. 

https://www.youtube.com/watch?v=XMdtCe_po9Y

I had watched Centipeed gameplay on YouTube quite a few times over the last couple of days and I was wondering how I was going to do the spider movement and then I realized I could script the movements.  I made 4 strings of a small command set consisting of the following:

U = straight up
V = diagonal right up
D = straight down
E = diagonal left down
R = right
W = diagonal left up
L =  left
A = diagonal down left

And I made sure the strings had enough commands to bring the spider from one side of the game matrix to the other side. I track the index of the selected "script" in the spider data record and in the drawspider procedure I use a case to set the row/column changes.

Here are procedures to set the initial position and script string and the drawing routine just to illustrate the script reading. The initial setting of spider.pathstring is done with a call to Setspider(random(maxrow-5)+1,0,random(4)+1);  if the spider goes out of matrix range it is declared dead.

I'll post a video of the finished game. I'm going to see about adding sound effects.

Also here is a sample of one of the scripts:
Code: Pascal  [Select][+][-]
  1. Const
  2. spath2 = 'RRREERRRRUUUUWWWWAAAARRRRREEEEEERREEERVVVVUUUUUUDDDDDDDDRRRVVVVEEEDDDDRRRVVWWVRRR';
  3.  
  4.  


Code: Pascal  [Select][+][-]
  1. Procedure SetSpider(R,c,WhichPath:integer);
  2. begin
  3. With spider do
  4. begin
  5.      Sindex := 1;
  6.      Row := r;
  7.      Column := c;
  8.      Dead := false;
  9.  Case WhichPath of
  10.         1:Pathstring := Spath1;
  11.         2:PathString := Spath2;
  12.         3:PathString := Spath3;
  13.         4:PathString := Spath4;
  14.  end;
  15. end;
  16. end;
  17.  
  18. Procedure DrawSpider;
  19. var
  20.   rd,cd:integer;
  21.   rr,cc:integer;
  22.   P:PointType;
  23.   s:string;
  24.   ch:char;
  25. begin
  26. cd := 0; rd:= 0;
  27. with spider do
  28. begin
  29. if not dead then
  30. begin
  31.   s := copy(pathstring,sindex,1);
  32.   ch := s[1];
  33.   case ch of
  34.    'U':RD := -1;
  35.    'D':RD := 1;
  36.    'V':BEGIN
  37.           RD := -1;
  38.           CD := 1;
  39.        END;
  40.    'E':BEGIN
  41.          RD := 1;
  42.          CD := 1;
  43.        end;
  44.    'R':CD := 1;
  45.    'L':CD := -1;
  46.    'W':begin
  47.          cd := -1;
  48.          rd := -1;
  49.       end;
  50.    'A':BEGIN
  51.          cd := -1;
  52.          rd := 1;
  53.         end;
  54.   end;// CASE
  55. whereisRC(row,column,p);  // translates row,column to a PointType of variable.
  56. for rr := 0 to 7 do
  57.   for cc := 0 to 5 do
  58.     if spiderchar[rr,cc] <> 0 then putpixel(p.x+cc,p.y+rr,spiderchar[rr,cc]);  
  59.  
  60. if gamegrid[row,column].Occupant = mushroom then gamegrid[row,column].Occupant:= empty;
  61.   row := row+rd;
  62.   column := column+cd;
  63.   If row > maxrow then dead := true;
  64.   if column > maxcol then dead := true;
  65.   If row < 0 then dead := true;
  66.   if column <0 then dead := true;
  67. end;
  68. inc(sindex);
  69.  if sindex > length(pathstring) then dead := true;
  70. end; // with spider
  71.     frametick(180);
  72. end;            
  73.  
  74.  
I love programming.


Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

 

TinyPortal © 2005-2018