Code a game competition Nov-Jan 2018 - Minimum £500 prize fund

Started by Qube, November 15, 2017, 04:44:30

Previous topic - Next topic

RemiD

Yes, that's what i have understood and do at the moment... Thanks for the clarification.

Scaremonger

I've got a lot done this evening.

* Manually created an 8x6 pixel character set loosely based on MSX characters.
* Created a text sprite that displays a string drawn in the custom character set (Resolution corrected).
* Implemented a basic 16 colour palette and fgcolor() function to use instead of setcolor()
* Created graphics for the player "ship" and added as a sprite
* Created Lobby graphic for game title
* Created player object with UP/DOWN and Fire controls
* Added laser sprite.
* Fixed sprite image scaling and tested to make sure that it is Resolution corrected.
* Created some sound effects with SXFR (Not implemented)
* Bug-fixes.

iWasAdam

nothing to show. ah ok, how about the ghoul:

He lives in a cage and is omnipresent. So clear the level before the cage is raised and ghoul gets free...

Sorta working on extra lives now. not quite sure how then will operate yet?

decided that one random monster per level might be one of the extra monsters!


collect enough to spell EXTRA and you get an extra life - yay!!!!!

NRJ

@iWasAdam

It's good to see your game progress day by day, your all screenshots look very good.
IF YOU CAN DREAM IT,  YOU CAN DO IT...

http://www.nksoftgames.blogspot.com

iWasAdam

still lots to do, more polish, bug catching, and everything else. lol

RemiD

Here is a code to "clean" your image, because when you draw/paint/select/copy/cut/paste some parts of an image, some image editors add some "progressive outline" around the shape, but since we want to have only a limited number of colors in the image, we have to identify the pixels of a similar color and to replace them by the wanted color.

I know, i probably should use a better image editor, but i don't want to waste time relearning the basics...

how to use this bb code : (that you can convert in bmx, of course)

define the "wanted colors" ->these are the main colors that you have used when drawing/painting, but then the "progressive outline" functionality messed everything !

define the "tolerance" -> this is to consider pixels which have a similar color than a wanted color as if they are of the wanted color.

define the "unknown color" -> this is to color the pixels which are too different from a wanted color, to the color you want (for example black)

then it outputs the "clean" image.

this seems to work correctly (oh yeah ! 8) )


Global PixAlpha% = 0
Global PixRed% = 0
Global PixGreen% = 0
Global PixBlue% = 0

Function WritePix(PX%,PY%,R%,G%,B%,A%=255)
HexARGB = RGBAToHexARGB(R,G,B,A)
WritePixel(PX,PY,HexARGB)
End Function

Function ReadPix(PX%,PY%)
HexARGB% = ReadPixel(PX,PY)
HexARGBToRGBA(HexARGB%)
End Function

Function WritePixFast(PX%,PY%,R%,G%,B%,A%=255)
HexARGB = RGBAToHexARGB(R,G,B,A)
WritePixelFast(PX,PY,HexARGB)
End Function

Function ReadPixFast(PX%,PY%)
HexARGB% = ReadPixelFast(PX,PY)
HexARGBToRGBA(HexARGB%)
End Function

Function RGBAToHexARGB%(R%,G%,B%,A%)
HexARGB% = A Shl(24) + R Shl(16) + G Shl(8) + B Shl(0)
Return HexARGB
End Function

Function HexARGBToRGBA(HexARGB%)
PixAlpha = HexARGB Shr(24) And 255
PixRed = HexARGB Shr(16) And 255
PixGreen = HexARGB Shr(8) And 255
PixBlue = HexARGB Shl(0) And 255
End Function

;image colors cleaner
Graphics(500,312,32,2)

SeedRnd(MilliSecs())

;load InImage
InFileName$ = "x.png"
InImage = LoadImage(InFileName)
InPWidth% = ImageWidth(InImage) : InPHeight% = ImageHeight(InImage)

;wanted colors to identify and keep
Global WantedsCount%
Dim WantedR%(16)
Dim WantedG%(16)
Dim WantedB%(16)

WantedsCount = WantedsCount + 1 : I% = WantedsCount
WantedR(I) = 000 : WantedG(I) = 000 : WantedB(I) = 000 ;a color that you want to keep

WantedsCount = WantedsCount + 1 : I% = WantedsCount
WantedR(I) = 255 : WantedG(I) = 255 : WantedB(I) = 255 ;a color that you want to keep

WantedsCount = WantedsCount + 1 : I% = WantedsCount
WantedR(I) = 090 : WantedG(I) = 060 : WantedB(I) = 030 ;a color that you want to keep

;tolerance
Global Tolerance% = 20 ;to consider pixels which have a similar (less or more) color (R,G,B values)

;unknown color
Global UnknownR = 000
Global UnknownG = 000
Global UnknownB = 000

Dim PixelWantedI%(1024,1024) ;link to wanted color

;analyze InImage
SetBuffer(ImageBuffer(InImage))
LockBuffer(ImageBuffer(InImage))
For PX% = 0 To InPWidth-1 Step 1
For PY% = 0 To InPHeight-1 Step 1
  ReadPixFast(PX,PY)
  For I% = 1 To WantedsCount Step 1
   ;if color of pixel is similar to a Wanted color
   If( PixRed > WantedR(I)-Tolerance And PixRed < WantedR(I)+Tolerance And PixGreen > WantedG(I)-Tolerance And PixGreen < WantedG(I)+Tolerance And PixBlue > WantedB(I)-Tolerance And PixBlue < WantedB(I)+Tolerance )
    ;keep it
    PixelWantedI(PX,PY) = I
   EndIf
  Next
Next
Next
UnlockBuffer(ImageBuffer(InImage))

;create OutImage
OutImage = CreateImage(InPWidth,InPHeight)
SetBuffer(ImageBuffer(OutImage))
LockBuffer(ImageBuffer(OutImage))
For PX% = 0 To InPWidth-1 Step 1
For PY% = 0 To InPHeight-1 Step 1
  I% = PixelWantedI(PX,PY)
  ;if pixel not similar to a wanted color
  If( I = 0 )
   ;color it with the unknown color
   R% = UnknownR : G% = UnknownG : B% = UnknownB
  ;if pixel similar to a wanted color
  Else If( I > 0 )
    ;color it with the wanted color
   R% = WantedR(I) : G% = WantedG(I) : B% = WantedB(I)
  EndIf
  WritePix(PX,PY,R,G,B)
Next
Next
UnlockBuffer(ImageBuffer(OutImage))

;save OutImage
OutFileName$ = Left(InFileName,Len(InFileName)-4)+"-cleaned"+".bmp"
SaveImage(OutImage,OutFileName)

End()


if you find any error/bug, please let me know...

Derron

I have also functions to find "nearest color" - so you define your palette and then iterate through your image's pixels and it switches the existing one with the ones being nearest according to the defined scheme (L*AB color or simple RGB if you want).

It is nothing one should do realtime but it allows for a nice image-cleanup during "loading assets" phase.

If there is interest in it (BlitzMax code) then I will post it - or link to the github files containing it (and my santa game) ;-)


bye
Ron

RemiD

the code i posted is to "clean" each image when making your assets (images), no need to use this during loading, this is not necessary...

Derron

Of course you could use my code for "cleaning" too. I use this to be able to switch to a slightly better suiting palette at the end without redoing the sprites (which might lay in different files).


bye
Ron

RemiD

I have just thought about a second method to determine the "best" wanted color of the remaining "unknown" pixels. (basically, analyze the pixels at left, right, up, down, upleft, upright, downleft, downright, of each remaining "unknown" pixel, and depending on the colors found, choose the final color...)

STEVIE G

Quote from: iWasAdam on December 15, 2017, 08:31:19
nothing to show. ah ok, how about the ghoul:

He lives in a cage and is omnipresent. So clear the level before the cage is raised and ghoul gets free...

Sorta working on extra lives now. not quite sure how then will operate yet?

decided that one random monster per level might be one of the extra monsters!


collect enough to spell EXTRA and you get an extra life - yay!!!!!


A bit of the old Chucky Egg I see  ;D  Loves that game for the Beeb.


Quick update ...

I managed to get barrier masks working and sort collisions to prevent any penetration.  Decided to make the track a little wider too which gives you a bit more room for overtaking.



The game is going to be simple.  You (or player 2) must win the race to progress to the next, otherwise it's game over and hi-score time.  The AI will start off shite and get slowly better after each race and slowly more hazards will be introduced.  Points are awarded for laps complete, best laps and your position in the race.  Bonus points can be picked up during the race.  You can upgrade your car's acceleration / top speed and traction once you've got 3 wrenches (up to a maximum of 5 times for each).  I plan on having 8 tracks which can also be raced in reverse so 16 in total. 

Sound familiar?  ;)   

I'm going to start working on a better particle system for crashes and tire smoke and then on to the menu's etc...
Not long to go but hopefully get it all done.

Steve Elliott

Quote
A bit of the old Chucky Egg I see  ;D  Loved that game.

Me too.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

therevills


Scaremonger

First Screenshot (With embedded Palette) and lots to do but I'm pretty pleased with what I've done so far in just 5 evenings.

Currently I can go up, down and fire (at nothing).

Next up will be getting the surface and other things scrolling to the left/right depending on the direction of travel and of course, add some enemies and some of the background graphics.


therevills

2 quick rules clarification please:

1. Is black a colour and does it count to one of the 16?
2. I like fading to black between sections (eg title screen to game screen), so I draw a black rectangle and tween its alpha until fully opaque - is this allowed as it may look like more colours are used?