Posted: 3rd Dec 2021 17:34
In the early days, several of us participated in code challenges in DBC and DBP as set by the forum community. This went on fairly consistently between 2005 and 2010 and now I'd like to bring it back for AGK.

For those new to the forum (new as in the last 10 years), the rules are simple.

Rules:
1. Code must be runnable with a simple copy and paste from forum to the IDE. (Tier 1 code only)
2. No external media. Graphics and sound must be generated with code. This includes no downloading/linking to online files elsewhere.
3. The person who selected the challenge is the judge. Should they fail to select a winner within a reasonable time after the challenge ends then the previous challenge's runner-up will be responsible for selecting a winner.
4. Challenge winners are tasked with choosing the next challenge in which they will judge.
5. Judges may enter for fun, but cannot be selected as a winner of their own challenge


As TGC currently has a larger competition going on right now I'd like to keep this short and simple. Perhaps as a small break for those working on their tower defense games and give them a chance to clear their heads.

Challenge: Screen saver
Deadline: Monday , Dec 6 at midnight (you got the weekend)
Details: Think of the old star field screen saver, or the bouncy lines. Maybe some 3D text bouncy around.
Posted: 4th Dec 2021 5:27
I'm using AGKS and I'm not used to playing with 2D but thought I'd have a go.
Key P to save a screenshot.
You can change sprite_total=5000 from 1 to as high as you like.

+ Code Snippet
// Project: ScreenSaver_ando 
// Created: 21-12-04

width# = GetMaxDeviceWidth()
height# = GetMaxDeviceHeight()
SetWindowSize(width#,height#,1)
SetVirtualResolution(width#,height#)
SetSyncRate(30,0)
SetScissor(0,0,0,0)
UseNewDefaultFonts(1)
SetSkyboxVisible(1)
SetSkyBoxHorizonColor(0,0,0)

sprite_total=5000
dim sprite[sprite_total]

xpos=width#/2
ypos=height#/2
change_time=250
xsize=Random(1,width#/20)
ysize=Random(1,height#/100)
R_color=Random(5,255)
G_color=Random(5,255)
B_color=Random(5,255)
angle=Random(1,60)-30
setrawmousevisible(0)

//  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  screenshot setup

screenGrab = CreateRenderImage(GetMaxDeviceWidth(),GetMaxDeviceHeight(),0,1)
filesavetext=createtext("")
settextvisible(filesavetext,0)

//  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

do

//  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  screenshot section
	
	if GetRawKeyPressed(80)				// P to save screenshot
		SetRenderToImage(screenGrab, -1)
		if gettextvisible(filesavetext) then settextvisible(filesavetext,0)
		number = 1
		ClearScreen()
		Render()
checkFiles:
		if GetFileExists("raw:"+GetReadPath()+"screenshots/Screenshot"+str(number)+".png")
			number = number + 1
			goto checkFiles
		endif
		SaveImage(screenGrab, "raw:"+GetReadPath()+"screenshots/Screenshot"+str(number)+".png")
		settextstring(filesavetext," Image saved as Screenshot"+str(number)+".png in "+ GetReadPath()+"screenshots")
		SetTextSize(filesavetext,GetMaxDeviceHeight()*0.0275)
		textTimer = 1
		SetRenderToScreen()
		if not gettextvisible(filesavetext) then settextvisible(filesavetext,1)
	endif
	
	If textTimer > 0 Then textTimer = textTimer + 1
	If textTimer > 299
		settextvisible(filesavetext,0)
		textTimer = 0
	EndIf
	
//  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  end screenshot section

    If change_time>299
        angle=Random(1,60)-30
        R_color=Random(5,255)
        G_color=Random(5,255)
        B_color=Random(5,255)
        xstep=Random(1,width#/125)-width#/250
        ystep=Random(1,height#/70)-height#/140
        xsize=Random(1,width#/10)
        ysize=Random(1,height#/500)
        change_time=Random(1,290)
        newangle=Random(1,100)-50
    EndIf
    
    change_time=change_time+1
    
    count=count+1
    if count<sprite_total+1
        if sprite[count]=0
            sprite[count]=CreateSprite(0)
        endif
        SetSpriteColor(sprite[count],R_color,G_color,B_color,255)
        SetSpriteSize(sprite[count],xsize,ysize)
        lastangle=lastangle-newangle
        SetSpriteAngle(sprite[count],lastangle+angle)
        SetSpritePosition(sprite[count],xpos+xstep,ypos+ystep)
        xpos=GetSpriteX(sprite[count])
        ypos=GetSpriteY(sprite[count])
        lastangle=GetSpriteAngle(sprite[count])
        If xpos > width# Then xpos=0
        If xpos < 0 Then xpos=width#
        If ypos > height# Then ypos=0
        If ypos < 0 Then ypos=height#
    Else
        count=0
    endif
    
    Sync()
    if GetrawKeyPressed(27) then exit
loop


Posted: 4th Dec 2021 11:20
Hi there
@ando That looks really nice let see if I find something to add here

Cheers.
Posted: 4th Dec 2021 12:30
Glad you like it. It's a little mesmerizing too.
Posted: 4th Dec 2021 14:34
That's pretty cool, good first entry! Hope we see more
Posted: 5th Dec 2021 20:15
Hi There. I have tried to convert some of my old darkbasic codes, but in AppGameKit some graphical commands work differently . Now that we are in christmas parties , trying to emulate ando's code , I made something like christmas twiddler ....nothing serious ....just to bring up this thread.

+ Code Snippet
// Project: screen saver 
// Created: 2021-12-05

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "screen saver" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

x=300
y=250
spt=1
r=255
g=0
b=0
cl=0
createsprite(spt,0)
setspritesize(spt,1024,768)
setspritecolor(spt,150,150,255,255)
sync()
do
  
for i= 1 to 20
  x=x+cos(giro)*3
  y=y+sin(giro)*3
  if random(0,10)=1
    giro=random(0,360)
  endif
  
  if y<30 or y>700 or x<30 or x>900
	  r=random(0,255):g=random(0,255):b=random(0,255)
	  y=400
	  x=400
  endif
  
  inc spt,1
  inc cl,1
  if cl>30 then cl=0
  createsprite(spt,0)
  SetSpritePosition(spt,x,y)
  setspritecolor(spt,r-cl,g-cl,b-cl,255)
  setspritesize(spt,100,5)
  setspriteangle(spt,random(0,360))
 next

sync()
loop
Posted: 5th Dec 2021 22:06
Nice! And the graphics are very fast!
Posted: 6th Dec 2021 4:37
Very basic starfield, Memories...

+ Code Snippet
// Project: stars screen saver 
// Created: 2021-12-05 by Rich Dersheimer

// set window properties
W = GetDeviceWidth()
H = GetDeviceHeight()
SetScreenResolution(0,0)
SetWindowSize(W,H,1)

id = CreateParticles(50,50)
SetParticlesSize(id,.2)
SetParticlesLife(id,30)
SetParticlesDirection(id,5,5 )
AddParticlesColorKeyFrame(id,0,255,255,255,0)
AddParticlesColorKeyFrame(id,2,255,255,255,255)

x1 = GetRawMouseX()
y1 = GetRawMouseY()
x2 = x1
y2 = y1

do
	if GetRawLastKey( ) <> 0 then end
	
	x1 = GetRawMouseX()
	y1 = GetRawMouseY()
    
	if x1=x2 AND y1=y2
		Sync()
	else
		end
	endif
	
	x2 = GetRawMouseX()
	y2 = GetRawMouseY()

	if GetRawMouseLeftReleased() then end

    Sync()
loop
Posted: 6th Dec 2021 5:25
why not?

+ Code Snippet
// Project: drop 
// Created: 2021-12-05
// By: Virtual Nomad
// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "drop" )
SetWindowSize( 640,360, 1 )
SetWindowAllowResize( 1 )

// set display properties
SetVirtualResolution( 640,360)
SetOrientationAllowed( 1, 1, 1, 1 )

SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 ) 

GLOBAL Red, Green, Blue, Drop
Red = MakeColor(255,0,0)	:	Green = MakeColor(0,255,0)	:	Blue = MakeColor(0,0,255)
for x = 4 to 48 step 4
	DrawEllipse(48,48,x,x,red,red,0)
	DrawEllipse(48,48,x-1,x-1,green,green,0)
	DrawEllipse(48,48,x-2,x-2,blue,blue,0)
next x
render()
Drop = GetImage(0,0,97,97)
Drop = CreateSprite(drop)	:	SetSpriteVisible(drop,0)
GLOBAL Drops as Integer []
SetRawMouseVisible(0)
do
	if last# + 1 < timer()
		drop()
		last# = timer()
	endif
	DoDrops()

    If GetRawKeyState(27) then Exit    

    Sync()
loop

Function Drop()
	ThisDrop = CloneSprite(Drop)
	SetSpriteVisible(ThisDrop,1)
	SetSpritePositionByOffset(ThisDrop,Random(0,639), Random(0,359))
	Drops.Insert(ThisDrop)
EndFunction

Function DoDrops()
	For x = Drops.Length to 0 Step -1
	Scale# = GetSpriteScaleX(Drops[x])
	If Scale# < 20.0
		SetSpriteScaleByOffset(Drops[x],Scale# + 0.1,Scale# + 0.1)
	Else
		DeleteSprite(Drops[x])
		Drops.Remove(x)
	Endif
	next x
EndFunction
Posted: 6th Dec 2021 9:07
I've not used a screensaver for many years but back then I always used the starfield. Too much star trek I guess.

The drop screensaver.... it looks cool but I think I'm sitting too close to a big screen for that one. Messes with my head.

Cool what you can do with so little code.
Posted: 6th Dec 2021 10:38
Fun examples here. I'm not trying to compete but to fiddle with the code a bit . I don't even know if we can put more than one example ....any way here's an old code I made when I started with Agk.

+ Code Snippet
// Project: himnotic 
// Created: 2018-11-25

// show all errors
SetErrorMode(2)

// set window properties
SetWindowTitle( "himnotic" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window

// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 60, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts

for i= 1 to 1000
   //ink rgb(rnd(255),rnd(255),rnd(255))
   //dot rnd(100),rnd(100)
   w=random(0,100)
   h=random(0,100)
   col=makecolor(random(0,255),random(0,255),random(0,255))
   drawline(w,h,w,h,col,col)
next i
getimage(1,0,0,100,100)

for i= 1 to 160
	createobjectsphere(i,i*0.05,20,20)
	setobjectimage(i,1,0)
	SetObjectTransparency(i,1)
next

setcameraposition(1,0,3,-6)
SetCameraRange(1,0.01,2000)
do
     //if ( GetRawKeyState( 38 ) ) then MoveCameraLocalZ( 1, 0.3 )  // cursor up
	 //if ( GetRawKeyState( 40 ) ) then MoveCameraLocalZ( 1, -0.3 ) // cursor down
  g#=g#+0.004
  
  setobjectrotation( 1,g#,g#,g#)
  for i= 2 to 160
	  setobjectrotation(i,i*g#,i*g#,i*g#)
	  setobjectscale(i,getobjectsizemaxx(i)-g#/2,getobjectsizemaxx(i)-g#/2,getobjectsizemaxx(i)-g#/2)
  next i
   
    Sync()
loop



Posted: 6th Dec 2021 11:17
OK chafari, that one looks so good. Wow.
Posted: 7th Dec 2021 16:55
@chafari that first one makes me think of tinsel.

Starfield is always a classic

I think Virtual Nomad is trying to trigger a seizure in me!


I don't even know if we can put more than one example

You can submit as many entries as you want.
Posted: 11th Dec 2021 13:46
it's well past the deadline and i want to see this continue so, if i may step in as the alt judge:

rich: classic with effective utilization of our toolbox in particle usage and the only entry to consider mousemove functionality as a screensaver. for me, that should have continued to include fullscreen functionality but stirred forgotten memories of "it's magic!" so +1

VN: fullscreen functionality as a screensaver "protecting" every pixel on the screen from burn. alas, may bend the mind (which i personally don't mind but not generally acceptable behavior)

ando: that's purdy tho complete randomness can allow for much of the screen to be ignored and some pixels left to burn. +1 for raising the bar in aesthetics right off the bat. +1 for savescreen, -1 for filling up my harddrive

chafari's xmas twidler: effectively declares it's intention and paints the picture. it seemed like some hidden AI was guiding the brush which was fun to watch.

chafari's himnotic: adds the next dimension and fills the screen with goodness. this is the type of screensaver i remember staring at for hours.

winner:
+ Code Snippet
chafari's himnotic

i'd be scared if you WERE trying to compete :)


now, see Rule 4 above

and, yes, i did note the post time vs deadline. as the starter challenge, i saw it as a soft deadline, so... going forward, judges should declare GMT/time zone? i used this site for the TD comp to make sure we are all using the same clock: http://time.unitarium.com/utc/1159pm
Posted: 11th Dec 2021 19:36
Yes, meditate with himnotic. All other worldly thoughts fall away....as......I........stare......at...........
Posted: 12th Dec 2021 9:58
Hi there.
I have never won anything in my life...I feel like a kid with a pocket full of candy Do you remember the famous snes mode 7 ... I always wondered how they could get that effect on those old computers....it was like a mix of old raycasting adding a ground .

You could create a scene in mode 7 and some objects such as trees, animals etc that rotate in 360? while we move with the camera. I know that we are now somewhat busy with the Christmas holidays so instead of one weekend , you have to weeks time, in order to have much more time with our family .

Challenge: mode 7
Deadline: Sunday , Dec 26 at midnight (you got two weeks)
Details: you could try something like a floor with some objects or a raycasting with some enemies


Edit : All must be made in 2D drawing as in the past old PC
Here's an example I made some time ago in TIC 80 fantasy console .

Posted: 12th Dec 2021 14:04
mode 7

ouch. i may try to fake it.
Posted: 13th Dec 2021 11:51
Yah, those equations are way beyond my limited math skills, but I have an idea on ?faking it? as well.
Posted: 13th Dec 2021 22:05
Don't let the math spook you. Just translate the code
Posted: 13th Dec 2021 23:51
Sorry everyone! Pretty bad when the guy tries to kickstart this fails to show up. My brother got shot last week and this thing just totally slipped my mind. Or maybe I just secretly wanted to test the rules and see if anyone would carry on in my absence!

Glad to see a spark in interest and everything has continued.