anthonybartram
Posts: 18
Joined: Wed Apr 29, 2015 11:03 pm

New first person shooter written in BBC BASIC running on RISC OS on the Raspberry Pi

Sun Jun 03, 2018 11:20 pm

Hi,

So far I've written 10 games on over the last 3 years developed with the Raspberry Pi.

The latest is a first person shooter written in BBC BASIC and running at up to 60 fps using PlOT 85 (the triangle command) for the vector graphics and system sprite scaling calls for 'billboarding' the zombies themselves.

A video is available here:
https://www.youtube.com/watch?v=XGyU4tVSzTM

A bit more inforamtion is available here:
http://www.amcog-games.co.uk/zombie.htm

I'm giving a talk a the WROCC club on the 6th of June on how this game works + demonstrating existing titles:
http://www.wrocc.org.uk/meetings/

Here are a few screenshots of the game:
Image
Image
Image

nobbit
Posts: 106
Joined: Sun Sep 25, 2011 5:51 pm

Re: New first person shooter written in BBC BASIC running on RISC OS on the Raspberry Pi

Mon Jun 04, 2018 8:41 am

This looks absolutely epic. Good work!

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19850
Joined: Sat Jul 30, 2011 7:41 pm

Re: New first person shooter written in BBC BASIC running on RISC OS on the Raspberry Pi

Mon Jun 04, 2018 10:59 am

Although this is a duplicate, I'm inclined to leave it up, since being hidden in the RISCOS forum doesn't give it the exposure it deserves.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10652
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: New first person shooter written in BBC BASIC running on RISC OS on the Raspberry Pi

Mon Jun 04, 2018 11:43 am

agreed

anthonybartram
Posts: 18
Joined: Wed Apr 29, 2015 11:03 pm

Re: New first person shooter written in BBC BASIC running on RISC OS on the Raspberry Pi

Mon Jun 04, 2018 10:20 pm

Thanks nobbit.

Also, thanks jamesh and mahjongg for letting me keep both posts.

Code fragment for those who are curious about the algorithm

I 've shared the algorithm below in case anyone finds it useful for their projects.

The game implements the painters algorithm (https://en.wikipedia.org/wiki/Painter%27s_algorithm) and billboarding (https://www.giantbomb.com/billboarding/3015-5074/)

For each frame
1) Handle player movement (PROCMovePlayer)
2) Move zombies (PROCTileBlock3DDoEnemy)
3) Project 12x12 map and objects near players location - so as to avoid processing more of the map than necessary i.e. for speed (PROCProjectLevel)
4) Ensure that the projected objects and vectors are positioned at the graphics origin i.e. so that rotation is about 0,0.
5) Rotate the billoarded objects and vectors so that the 'camera' is facing in the current players direction (PROCDrawLevel).
6) The rest of the code updates the status display at the top of the screen and triple buffers the display.

Code: Select all

 
 REM This is the main loop where each frame is drawn
REPEAT
  REM For simplicity clear the current video buffer before drawing each frame
  CLS

  PROCMovePlayer

  FOR I% = 0 TO NUMZombie%-1
    IF ZombieA%(I%) > 0 AND ZombieA%(I%) < defZombieDie0% THEN
      PROCTileBlock3DDoEnemy(LEVELDATA%, tiles_timed%, (IX+4.5) * defD%, (IY+5.5) * defD%, ZombieX%(I%), ZombieY%(I%), ZombieS%(I%), def_mode_home% + def_mode_random%, ZombieDir$(I%))
      IF ZombieFear%(I%) > 0 THEN ZombieS%(I%) -= 2 : ZombieFear%(I%) -= 1
    ENDIF
    IF ZombieA%(I%) >= defZombieDie0% AND (ANIM% MOD 3)= 0 THEN
      ZombieA%(I%) += 1
      IF ZombieA%(I%) > defZombieDie4% THEN ZombieA%(I%) = 0
    ENDIF
  NEXT

  PROCProjectLevel(LEVELDATA%, IX, IY)

  REM Move to origin prior to rotation so that map fragment is viewed at camera direction
  FX% = (IX - INT(IX))*defD0%
  FY% = (IY - INT(IY))*defD0%

  REM Translate projection
  FOR I% = 1 TO NUMPTS%
      PTS%(I%, 2) += FX%
      PTS%(I%, 0) += FY%
  NEXT

  PROCRotatePoints(angle%,defXbase%+RX%,defYbase%+RZ%)

  REM Now draw the level in z buffer order
  PROCDrawLevel

  REM Print the current score
  PROCPrint("Score: ", "Corpus.medium", 20, 50, 1160, 1)
  PROCPrint(STR$(SCORE%), "Corpus.medium", 20, 50, 1108, 1)

  PROCPrint("Level:", "Corpus.medium", 20, 750, 1160, 1)
  PROCPrint(STR$(LEVEL%),  "Corpus.medium", 20, 750, 1108, 1)

  PROCPrint("Fuel Required:", "Corpus.medium", 20, 50, 1060, 1)
  PROCPrint(STR$(Required%),  "Corpus.medium", 20, 50, 1008, 1)

  PROCPrint("Ammo:", "Corpus.medium", 20, 500, 1160, 1)
  PROCPrint(STR$(AMMO%),  "Corpus.medium", 20, 500, 1108, 1)

  PROCPrint("Health:", "Corpus.medium", 20, 750, 1060, 1)
  PROCSpritePut("healthlevel", 750, 1008)
  PROCSpritePut("eraselevel", 750+(HEALTH%*2), 1008)

  PROCSpritePut("device", 1000,980)
  PROCSpritePut("gps", 1040,1014)

  REM Draw Angle
  GCOL 0,255,0
  MOVE 1225, 1150
  A% = angle% - 45
  IF A% <0 THEN A% += 360
  A% = A% MOD 360
  A% = 360 - A%
  DRAW 12*tableCos(A%)+12*tableSin(A%)+1225, (-12*tableCos(A%)-(-12*tableSin(A%)))+1150

  A = INT((IX - INT(IX)) * 10)
  B = INT((IY - INT(IY)) * 10)

  VDU 5
  GCOL 0,0,0 : RECTANGLE FILL 1225,1000,150,24
  PROCTextPlain(1230,1010,"X:"+STR$(INT(IX))+"."+STR$(A),20,6,8)
  PROCTextPlain(1300,1010,"Y:"+STR$(INT(IY))+"."+STR$(B),20,6,8)

  REM Auto restart the music if it reaches the end or change
  REM to the next track if one is configured
  PROCTrackPlayer(musicLength%(), musicMP3$())
  PROCTripleBuffer

UNTIL DONE OR (ALIVE = 0)
 
  
Best Regards,
Tony.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 9 guests