Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: GfxFreak on October 03, 2012

Title: Zoom in Chessboard Algo?
Post by: GfxFreak on October 03, 2012
Hi , i have a problem in my Chessboard algo.

This is my code:

Code: [Select]
For x As Integer = 0 To screen_width -1

For y As Integer = 0 To screen_height-1

_color =255 *  ((((x+mx) Shr 4) And 1 )  xor (((y+my) Shr 4) And 1) )

SetPixelFast(x,y,RGB(_color,255-(x/2),155-(y/2)))

Next

Next

mx = Sin(timer) * 100
my = Cos(timer) * 100

How I can add a Zoom algo in it?
Title: Re: Zoom in Chessboard Algo?
Post by: Rbz on October 04, 2012
You will need to play with x/y divisor, you could try something like this:

(This run terribly slow here, I just can't remember how to make things faster on blitzplus anymore :) )

Code: [Select]
AppTitle "xor"
Graphics 640,480,32,2
SetBuffer BackBuffer()

Global screen_width = 640
Global screen_height = 480

Global Col=0,mx#=0,my#=0

Global timer#,angle#,zoom#


While Not KeyHit(1)

  Cls


For x = 0 To screen_width -1

For y = 0 To screen_height-1

If zoom>0 Then
Col =255 *  ((((x+mx) / zoom) And 1 )  Xor (((y+my) / zoom) And 1) )
EndIf

Color col,col,col
Plot x,y
;SetPixelFast(x,y,RGB(_Color,255-(x/2),155-(y/2)))

Next

Next

timer = MilliSecs()

mx# = Sin(timer#) * 100
my# = Cos(timer#) * 100

zoom# = 100.0 + Sin(angle#)*80.0
    angle# = angle# + 10
    angle# = angle# Mod 360


 
  Flip
Wend