Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - Brick Redux

#46
Could you break down the Z ordering of sprites into an easy to understand method for us here? Its obvious that IF Y! is greater than Y2 display Y! over Y2 but when using multiple sprites within a ARRAY it often becomes confusing. Do you wrap the ARRAYs order to suit the screen to keep everything in order?

Your offering here is pretty amazing, thank you josemym2. 
#47
Nice one Schranz0r, thanks for sharing.
#48
Indeed, and life would become boring. 

I will tinker with your code and see what occurs.  Im the type of guy that (sometimes) takes something apart, puts it all back together and finds a few screws left over...cough :)
#49
Im surprised to find no replies here CW.  A good bit of field work that displays the efforts of a creative and intelligent coder.  Keep it up!
#50
Heres a scrolling version, needs streamlining.

Code (glbasic) Select
/////////////////////////////////////////////////////////////////////////
//
// 3D Chequerboard in 2D v.2
//
//
//
//

GLOBAL dir, grid, size, jump, scale, ypos, zpos, xpos, tilex[], tiley[], tilez[], polyx1[], polyy1[]
GLOBAL color, whichcolor, still_free_of_ESC, width, height, polyx2[], polyy2[], newcolor, newcolor1
GETSCREENSIZE width, height
GOSUB setup
GOSUB updatethegrid
/////////////////////////////////////////////////////////////////////////
//
// Loop
//
//

WHILE still_free_of_ESC



GOSUB drawthegrid

SHOWSCREEN

WEND

/////////////////////////////////////////////////////////////////////////


SUB drawthegrid:

whichcolor=1

FOR x = 0 TO grid-2

INC whichcolor

IF whichcolor>2
whichcolor=1
ENDIF

color = whichcolor

FOR z = 0 TO grid-2

INC color

IF color>2
color=1
ENDIF

tx = tilex[x][z] / tilez[x][z]
ty = tiley[x][z] / tilez[x][z]

polyx1[0]=-tx ; polyy1[0]=ty

polyx2[0]=tx ; polyy2[0]=ty

tx = tilex[x+1][z] / tilez[x+1][z]
ty = tiley[x+1][z] / tilez[x+1][z]

polyx1[1]=-tx ; polyy1[1]=ty

polyx2[1]=tx ; polyy2[1]=ty

tx = tilex[x+1][z+1] / tilez[x+1][z+1]
ty = tiley[x+1][z+1] / tilez[x+1][z+1]

polyx1[2]=-tx ; polyy1[2]=ty

polyx2[2]=tx ; polyy2[2]=ty

tx = tilex[x][z+1] / tilez[x][z+1]
ty = tiley[x][z+1] / tilez[x][z+1]

polyx1[3]=-tx; polyy1[3]=ty
polyx2[3]=tx; polyy2[3]=ty
//////////////////////////////////////////////////////////////////
// color

IF color = 1
newcol=RGB(255,255,255)
newcol1=RGB(0,0,180)
ELSE
newcol=RGB(0,0,180)
newcol1=RGB(255,255,255)
ENDIF

///////////////////////////////////////////////////////////////////
// Draw Tile
// cx & cy IN place but NOT used here for manipulating the board - ascend,descend,tilt left/right etc
//

STARTPOLY 0

POLYVECTOR  polyx1[0]+width/2,polyy1[0], 0, 0,newcol

POLYVECTOR  polyx1[1]+width/2,polyy1[1], 0, 0,newcol

POLYVECTOR  polyx1[2]+width/2,polyy1[2], 0, 0,newcol

POLYVECTOR  polyx1[3]+width/2,polyy1[3], 0, 0,newcol

ENDPOLY

STARTPOLY 0

POLYVECTOR  polyx2[0]+width/2,polyy2[0], 0, 0,newcol1

POLYVECTOR  polyx2[1]+width/2,polyy2[1], 0, 0,newcol1

POLYVECTOR  polyx2[2]+width/2,polyy2[2], 0, 0,newcol1

POLYVECTOR  polyx2[3]+width/2,polyy2[3], 0, 0,newcol1

ENDPOLY


NEXT
NEXT
///////////////////////////////////////////////////////////////////
// Scroll the grid
//
FOR z = 0 TO grid -1

FOR x = 0 TO grid -1

IF tilez[x][z]>0.23

DEC tilez[x][z] , 0.02

ELSEIF tilez[x][z]<0.23

tilez[x][z]=0.73 ; GOSUB updatethegrid

ENDIF

NEXT

NEXT


ENDSUB


SUB updatethegrid:

jump = size / grid

zpos = 8

FOR z = 0 TO grid -1

xpos = 10/scale

FOR x = 0 TO grid -1

tilex[x][z] = xpos
tiley[x][z] = ypos
tilez[x][z] = zpos

INC xpos, jump*scale

NEXT

INC zpos , -jump  / 20

NEXT

ENDSUB


SUB setup:

still_free_of_ESC=TRUE

grid = 30 ; size = 150

jump = size / grid ; scale = 35 ; ypos = 500 ; zpos = 8

DIM tilex[grid][grid] ; DIM tiley[grid][grid]
DIM tilez[grid][grid] ; DIM polyx1[9] ; DIM polyy1[9]
DIM polyx2[9] ; DIM polyy2[9]
ENDSUB


#51
2D-snippets / Re: 8-Bit Rain
2013-Apr-26
I was also a fan of the SuperCars games - top down view racing.

Regarding the fake 3d effect (snippet) Im sure its possible to achieve the Snes Mode 7 effect with it too.  Draw a large map sprite, choose a small area of said sprite and read the color values there. Then duplicate these color values onto the 3d grid snippet.  Doing corners would be quite easy - rotate the map sprite/ then scan the colors - achieving a fluid bend in the 3d grid.
#52
Alot of time and thought went into that and thats good.  Well done. 
#53
2D-snippets / Re: 8-Bit Rain
2013-Apr-26
Thanks to your code I ended up playing Lotus 2 again today.  A racing game that mimicks your rain code in a certain race. Im now looking forward to your game Erico.  Dont worry too much about messy code - in the 1990s alot of software developers coded games in the same way and they made money!  So, go with whats best for you and channel the creativity buddy.
#54
The cx and cy variables apart from being used to adjust hieght and slope can also produce warp effects to the grid.

One such effect I experimented with left a image similar to swirls/blades of grass.

Polyvector is a very powerful command indeed.
#55
Quote from: fuzzy70 on 2013-Mar-25
SETPIXEL is the problem with regards to being the major speed killer.

Drawline seemed to speed things up(instead of Setpixel) when I was using MEM2SPRITE for image editing. Even when plotting a single point. The only other solution on offer seemed to be Inline code that turns off Setpixels Safe mode.  Playbasic for example has a fast fill command that uses this. (But its limited in its use.)
#56
 :D

Its a real pleasure just for your replies.

:good:
#57
Its good to be back guys and here I present a Space Harrier style floor that moves.  Needs work but thats for you lot to deal with.

Cheers.

Mark

Code (glbasic) Select
/////////////////////////////////////////////////////////////////////////
//
// 3D Chequerboard in 2D
// A 50p Production
// in association with
// Jelly Babies and some coffee
//

GLOBAL dir, grid, size, jump, scale, ypos, zpos, xpos, tilex[], tiley[], tilez[], polyx[], polyy[]
GLOBAL color, whichcolor, still_free_of_ESC, needsomemorecoffee, andsomemoresugar
GOSUB setup

/////////////////////////////////////////////////////////////////////////
//
// Loop
//
//

WHILE still_free_of_ESC

GOSUB updatethegrid

GOSUB drawthegrid

SHOWSCREEN

WEND

/////////////////////////////////////////////////////////////////////////


SUB drawthegrid:

whichcolor=1

FOR x = 0 TO grid-2

INC whichcolor

IF whichcolor>2
whichcolor=1
ENDIF

color = whichcolor

FOR z = 0 TO grid-2

INC color

IF color>2
color=1
ENDIF

tx = tilex[x][z] / tilez[x][z]
ty = tiley[x][z] / tilez[x][z]

polyx[0]=tx ; polyy[0]=ty

tx = tilex[x+1][z] / tilez[x+1][z]
ty = tiley[x+1][z] / tilez[x+1][z]

polyx[1]=tx ; polyy[1]=ty

tx = tilex[x+1][z+1] / tilez[x+1][z+1]
ty = tiley[x+1][z+1] / tilez[x+1][z+1]

polyx[2]=tx ; polyy[2]=ty

tx = tilex[x][z+1] / tilez[x][z+1]
ty = tiley[x][z+1] / tilez[x][z+1]

polyx[3]=tx ; polyy[3]=ty
//////////////////////////////////////////////////////////////////
// Calculate color depth

shade=(ty/2)

IF shade<0
shade=50
ENDIF

IF color = 1
newcol=RGB(shade,shade,shade)
ELSE
newcol=RGB( 0,shade,0)
ENDIF

///////////////////////////////////////////////////////////////////
// Draw Tile
// cx & cy IN place but NOT used here for manipulating the board - ascend,descend,tilt left/right etc
//

STARTPOLY 0

POLYVECTOR  polyx[0]+cx,polyy[0]+cy,  0, 0,newcol

POLYVECTOR  polyx[1]+cx,polyy[1]+cy,  0, 0,newcol

POLYVECTOR  polyx[2]+cx,polyy[2]+cy,  0, 0,newcol

POLYVECTOR  polyx[3]+cx,polyy[3]+cy,  0, 0,newcol

ENDPOLY

NEXT
NEXT

ENDSUB


SUB updatethegrid:

jump = size / grid

zpos = 8

FOR z = 0 TO grid -1

xpos = scale

FOR x = 0 TO grid -1

tilex[x][z] = xpos
tiley[x][z] = ypos
tilez[x][z] = zpos

xpos = xpos + jump * scale

NEXT

INC zpos , -jump / 20

NEXT

INC size,dir

IF size<160 AND dir=0.1

INC size , 0.1 //....scrolls the board, erm sort of....cough

ELSE

dir=-0.1

ENDIF

IF size>150 AND dir=-0.1

DEC size , 0.1

ELSE

dir=0.1

ENDIF

ENDSUB


SUB setup:

dir=0.1 ; still_free_of_ESC=TRUE

grid = 30 ; size = 150

jump = size / grid ; scale = 25 ; ypos = 400 ; zpos = 8

DIM tilex[grid][grid] ; DIM tiley[grid][grid] ; DIM tilez[grid][grid] ; DIM polyx[9] ; DIM polyy[9]

ENDSUB


ark
#58
2D-snippets / Re: 8-Bit Rain
2013-Apr-25
Well done with that Erico, a nice parallax effect. :good:
#59
Cheers Lee & keep up the good work.
#60
Brilliant!