News:

Function Finder  Find all the functions within source code files

Main Menu

LowRes Pixel Mode (of particle demo)

Started by kevin, January 01, 2019, 10:32:52 AM

Previous topic - Next topic

kevin

  LowRes Pixel Mode (of particle demo)



    This is version of the New Years eve demo with the a LowRes pixel filter, which is made my simply scaling the image down and then up again.     


PlayBASIC Code: [Select]
      PixelSize=4



openscreen 1280,720,32,1

#include "blitimage"

//Variables
GLOBAL Speed#
GLOBAL parax#
GLOBAL paray#
GLOBAL paraz#
GLOBAL Angle1#
GLOBAL Angle2#

GLOBAL switch = 0
GLOBAL NbFeu = 500
GLOBAL Temps = 0


//Types

TYPE FeuArtifice
SpriteIndex
x#
y#
z#
vy#
xd#
yd#
zd#
size#
ENDTYPE

DIM Pouf AS FeuArtifice LIST

Dim ImageUsageCounters($ffff)


ParticleImage=MakeBall()

Screen=NewFXIMage(GetScreenWidth(),GetScreenHeight())

LowREsScreen = NewFXIMage(GetScreenWidth(),GetScreenHeight())

Global Screen_Width = GetScreenWidth()
Global Screen_Height = GetScreenHeight()




// Boucle principale
REPEAT
RendertoIMage Screen


; for pass=1 to 2
IF Temps = 0
parax# = RNDrange(-150,150)
paray# = RNDRange(-120,60)
paraz# = RNDRange( 150,400)

IF swith = 0
Temps = rndrange(10,60)
ENDIF

; pick a colour for this batch
ThisRGB=RNDRGB()
THisImage=PreColourIMage(ParticleImage,ThisRGB)

FOR i = 1 TO NbFeu
NewFeu(parax#,paray#,paraz#,ThisImage,THisRGB)
NEXT

ENDIF

t=timer()
FOR EACH Pouf()
if AfficheFeu()=0
KillParticle()
endif
NEXT
tt1#+=(timer()-t)
Temps--


; next


t=timer()
;DRAWALLSPRITES
TEST_MultiPass(Screen,Sprites_DRaw_mode,6)
tt2#+=(timer()-t)


rendertoscreen


Render_Logos(Screen,CurrentSaveFrame,MaxFramesInDemo,PixelSize)


rendertoimage Screen
BlitImageAlphaPostMultColour(Screen,0,0,$F0D8D8)

rendertoscreen
RenderAsLowres(Screen,Xpos,Ypos,PixelSize)


if LeftKey()
PixelSize=ClipRange(PixelSize-1,1,16)
flushkeys
endif

if RightKey()
PixelSize=ClipRange(PixelSize+1,1,16)
flushkeys
endif


setcursor 0,0
Text 10,10,"Pixel Size:"+str$(PixelSize)
SYNC

UNTIL ESCKEY() = 1



end






Function RenderAsLowres(ScreenImage,Xpos,Ypos,PixelSize)

static _LowResImage

local Width = GetImageWidth(ScreenImage)
local Height = GetImageHeight(ScreenImage)

if PixelSize>1
TargetSurface=GetSurface()

LR_Width = Width/PixelSize
LR_Height= Height/PixelSize

Login required to view complete source code