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.


Messages - fuzzy70

Pages: 1 ... 22 23 [24] 25 26 ... 36
346
Off Topic / Re: Raspberry Pi
« on: 2012-Feb-29 »
TBH why spoil a funky piece of hardware by infecting it with a Microsoft product  :D

347
Code Snippets / Re: DotBall
« on: 2012-Feb-29 »
Thats fun. I flippin love it.  =D

Couple of things I thought of. Try drawing the screen with ALPHAMODE 1.0 to see if you like the effect better than the default mode.  I wonder if you might also get a performance boost by replacing the DRAWRECT command with a series of POLYVECTOR sprites.

Glad you like it  =D

Not to sure about ALPHAMODE mainly because I have not played around with that command yet but will have a go. The DRAWRECT was used as I didn't like the way 1x1 pixels looked & just needed something quick to view the output, also POLYVECTORS are another area I need to play around with as no experience with them as such yet.

Lookup tables for SIN/COS might give a boost, not so much on PC's I think but some of the lower spec targets like WinCE, Cannoo etc might benefit from them.

It was more or less coded in 1 sitting so there are bound to be some further optimisations that can be made as I focused on the effect rather than the performance (as well as learning types a bit more).

Your comments for improvements/ideas are appreciated & welcomed, if anyone else has any please post them  =D

Lee

update:

  • Rolled the creation of the objects into the same type & made the type an array so you can create multiple objects easy if you need.
  • Doing the above has removed duplicate code somewhat
  • Added a "killobject" function to freeup memory
Code: [Select]
// --------------------------------- //
// Project: dotobject
// Start: Wednesday, February 29, 2012
// IDE Version: 10.244


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

// SETCURRENTDIR("Media") // go to media files

GLOBAL dobj[] AS dotobject, scx, scy, alphaloop, alphastep, ikey$

GETSCREENSIZE scx, scy

TYPE point
x
y
z
ENDTYPE

TYPE dotobject
xrot
yrot
zrot

objectpoints[] AS point

FUNCTION createball: pointcount

LOCAL theta, phi, loop

DIM self.objectpoints[pointcount]

FOREACH loop IN self.objectpoints[]

theta = RND (180)-90
phi = RND (359)
loop.x = (COS(theta) * 10) * (COS(phi) * 10)
loop.y = (COS(theta) * 10) * (SIN(phi) * 10)
loop.z = SIN(theta) * 100

NEXT

ENDFUNCTION

FUNCTION createcube: pointcount

LOCAL loop, across, down, side

DIM self.objectpoints[pointcount]

FOREACH loop IN self.objectpoints[]

side = RND (5)
across = RND (120)
down = RND (120)
SELECT side
CASE 0  // Front face
loop.x = across-60
loop.y = down-60
loop.z = 60
CASE 1  // Back face
loop.x = across-60
loop.y = down-60
loop.z = -60
CASE 2  // Left face
loop.x = -60
loop.y = down-60
loop.z = across-60
CASE 3  // Right face
loop.x = 60
loop.y = down-60
loop.z = across-60
CASE 4  // Top face
loop.x = across-60
loop.y = 60
loop.z = down-60
CASE 5  // Bottom Face
loop.x = across-60
loop.y = -60
loop.z = down-60
ENDSELECT

NEXT

ENDFUNCTION

FUNCTION drawobject: sx,sy,sz,posx=scx/2,posy=scy/2,scale=1

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.objectpoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = ((scale*512) * (tmpx) / (persp - (tmpz))) + (posx)
y  = (posy) - ((scale*512) * tmpy) / (persp - (tmpz))

colour = (tmpz+100) * 1.2

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION

FUNCTION killobject:
DIM self.objectpoints[0]
ENDFUNCTION

ENDTYPE


REDIM dobj[2]
dobj[0].createball(1000)
dobj[1].createcube(500)

alphaloop = -1
alphastep = 0.01
WHILE TRUE

ALPHAMODE alphaloop
dobj[0].drawobject(1,0.75,0.5,400,400,.25)
dobj[1].drawobject(0.5,0.75,1,250,150,1)

SHOWSCREEN
ikey$=INKEY$()
IF ikey$ = "0" THEN dobj[0].killobject()
IF ikey$ = "1" THEN dobj[1].killobject()
IF alphaloop > 1.0 THEN alphastep = -0.01
IF alphaloop < -1.0 THEN alphastep = 0.01
INC alphaloop, alphastep

WEND

348
Code Snippets / Re: DotBall
« on: 2012-Feb-29 »
Updated now so you can specify scale as well as position (both are optional parameters), hopefully fixed the colour scaling code to return ranges from 0-255, also added a dotcube for the fun of it  :D

Todo :
  • Add more objects like a torus, cylinder etc
  • Fix the cube code so that Z falls in the -100 to 100 range same as sphere (only for the colour code mainly)
  • Add a destroy function to clear the array
  • Breakout the common rotation code into it's own function
  • Numerous other little tweaks & fixes  =D

Lee
Code: [Select]
// --------------------------------- //
// Project: dotball
// Start: Tuesday, February 28, 2012
// IDE Version: 10.244


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

// SETCURRENTDIR("Media") // go to media files
GLOBAL DB AS dotball, DC AS dotcube, scx, scy

GETSCREENSIZE scx, scy

TYPE point
x
y
z
ENDTYPE

TYPE dotball
xrot
yrot
zrot

ballpoints[] AS point

FUNCTION createball: pointcount

LOCAL theta, phi, loop

DIM self.ballpoints[pointcount]

FOREACH loop IN self.ballpoints[]

theta = RND (180)-90
phi = RND (359)
loop.x = (COS(theta) * 10) * (COS(phi) * 10)
loop.y = (COS(theta) * 10) * (SIN(phi) * 10)
loop.z = SIN(theta) * 100

NEXT

ENDFUNCTION

FUNCTION drawball: sx,sy,sz,posx=scx/2,posy=scy/2,scale=1

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.ballpoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = ((scale*512) * (tmpx) / (persp - (tmpz))) + (posx)
y  = (posy) - ((scale*512) * tmpy) / (persp - (tmpz))

colour = (tmpz+100) * 1.2

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION


ENDTYPE

TYPE dotcube
xrot
yrot
zrot

cubepoints[] AS point

FUNCTION createcube: pointcount

LOCAL loop, across, down, side

DIM self.cubepoints[pointcount]

FOREACH loop IN self.cubepoints[]

side = RND (5)
across = RND (120)
down = RND (120)
SELECT side
CASE 0  // Front face
loop.x = across-60
loop.y = down-60
loop.z = 60
CASE 1  // Back face
loop.x = across-60
loop.y = down-60
loop.z = -60
CASE 2  // Left face
loop.x = -60
loop.y = down-60
loop.z = across-60
CASE 3  // Right face
loop.x = 60
loop.y = down-60
loop.z = across-60
CASE 4  // Top face
loop.x = across-60
loop.y = 60
loop.z = down-60
CASE 5  // Bottom Face
loop.x = across-60
loop.y = -60
loop.z = down-60
ENDSELECT

NEXT

ENDFUNCTION

FUNCTION drawcube: sx,sy,sz,posx=scx/2,posy=scy/2,scale=1

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.cubepoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = ((scale*512) * (tmpx) / (persp - (tmpz))) + (posx)
y  = (posy) - ((scale*512) * tmpy) / (persp - (tmpz))

colour = (tmpz+100) * 1.2

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION


ENDTYPE
DC.createcube(1000)
DB.createball(1000)

WHILE TRUE

DC.drawcube(0.5,0.75,1,250,150,1)
DB.drawball(1,0.75,0.5,400,400,0.5)

SHOWSCREEN

WEND



349
Code Snippets / Re: DotBall
« on: 2012-Feb-29 »
A simple change I just noticed from looking at the code ( & why I did not do it in the 1st place I have no idea ) is to add an x & y to the function call drawball so you can draw it where you like rather than centred. Have changed the code to do that now but you can leave the last 2 parameters off & it will centre it like before.

Lee

Code: [Select]
// --------------------------------- //
// Project: dotball
// Start: Tuesday, February 28, 2012
// IDE Version: 10.244


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

// SETCURRENTDIR("Media") // go to media files
GLOBAL DB AS dotball, scx, scy

GETSCREENSIZE scx, scy

TYPE point
x
y
z
ENDTYPE

TYPE dotball
xrot
yrot
zrot

ballpoints[] AS point

FUNCTION createball: pointcount

LOCAL theta, phi, loop

DIM self.ballpoints[pointcount]

FOREACH loop IN self.ballpoints[]

theta = RND (180)-90
phi = RND (359)
loop.x = (COS(theta) * 10) * (COS(phi) * 10)
loop.y = (COS(theta) * 10) * (SIN(phi) * 10)
loop.z = SIN(theta) * 100

NEXT

ENDFUNCTION

FUNCTION drawball: sx,sy,sz,posx=scx/2,posy=scy/2

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.ballpoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = (512 * (tmpx) / (persp - (tmpz))) + (posx)
y  = (posy) - (512 * tmpy) / (persp - (tmpz))

colour = tmpz + 155

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION


ENDTYPE


DB.createball(500)


WHILE TRUE

DB.drawball(1,0.75,0.5,200,200)

SHOWSCREEN

WEND



350
Code Snippets / DotBall
« on: 2012-Feb-29 »
Here is my attempt at making an oldschool dot ball, the rotation code I found laying around in an old word document of mine (along with other snippets) so I cannot say with total honesty if I wrote that part or not  :O

I mainly wrote this as an exercise of using functions in types which is slowly beginning to sink in at last & is probably far from the best example. Any suggestions of improvements or if/where I have failed would be welcomed

Code: [Select]
// --------------------------------- //
// Project: dotball
// Start: Tuesday, February 28, 2012
// IDE Version: 10.244


// FREE-VERSION:
// Need Premium for Features:
// 3D Graphics
// Network Commands
// INLINE C/C+++ code

// SETCURRENTDIR("Media") // go to media files
GLOBAL DB AS dotball, scx, scy

GETSCREENSIZE scx, scy

TYPE point
x
y
z
ENDTYPE

TYPE dotball
xrot
yrot
zrot

ballpoints[] AS point

FUNCTION createball: pointcount

LOCAL theta, phi, loop

DIM self.ballpoints[pointcount]

FOREACH loop IN self.ballpoints[]

theta = RND (180)-90
phi = RND (359)
loop.x = (COS(theta) * 10) * (COS(phi) * 10)
loop.y = (COS(theta) * 10) * (SIN(phi) * 10)
loop.z = SIN(theta) * 100

NEXT

ENDFUNCTION

FUNCTION drawball: sx,sy,sz

LOCAL tmpx, tmpy, tmpz, px, loop, persp, x%, y%, colour%

persp = 400

FOREACH loop IN self.ballpoints[]


tmpy = ((loop.y * COS(self.xrot)) - (loop.z * SIN(self.xrot)))
tmpz = ((loop.y * SIN(self.xrot)) + (loop.z * COS(self.xrot)))
tmpx = ((loop.x * COS(self.yrot)) - (tmpz * SIN(self.yrot)))
tmpz = ((loop.x * SIN(self.yrot)) + (tmpz * COS(self.yrot)))
px = tmpx
tmpx = ((tmpx * COS(self.zrot)) - (tmpy * SIN(self.zrot)))
tmpy = ((px * SIN(self.zrot)) + (tmpy * COS(self.zrot)))
x  = (512 * (tmpx) / (persp - (tmpz))) + (scx/2)
y  = (scy/2) - (512 * tmpy) / (persp - (tmpz))

colour = tmpz + 155

DRAWRECT x,y,2,2,RGB(colour,colour,colour)

NEXT

INC self.xrot , sx
INC self.yrot , sy
INC self.zrot , sz

ENDFUNCTION


ENDTYPE


DB.createball(500)


WHILE TRUE

DB.drawball(1,0.75,0.5)

SHOWSCREEN

WEND



Lee

351
GLBasic - en / Re: How do you implement UNDO?
« on: 2012-Feb-28 »
I done a similar thing to what Slydog mentioned a long while back. Basically grabbed the area that was being affected as a spritegrab & added the sprite ID in an type. The ID's where created sequentiality starting at a high number like 1000 then it was just a case of removing the 1st item in the list when it hit my undo limit (which was set to 50 I think).

To undo just redraw the sprite from the list (not the last item in the list as that is the current change I made). It has the advantage that you can redo so can flick between the last changes by redrawing the last item on the list.

Although it was very very basic it did achieve what I wanted to do. And like Slydog said it can be expanded.

Lee


also using types rather than arrays makes management easier. Deleting the 1st (lowest) entry in a list is quicker than having to move each item in an array down by one unless you want an unlimited undo list

352
Happy Birthday  :booze:

Lee

353
GLBasic - en / Re: Array speeds
« on: 2012-Feb-28 »
I don't get it, why do you call it 'GLB Results', where everything you do in that last snippet is straight C?

Ocean

The GLB Results where from the GLB program at the start of the thread, I mentioned the speed difference but not the timings. my bad

Lee

354
DD-GUI / Re: DDcreator
« on: 2012-Feb-28 »
Now that could be useful!

Am having the same thoughts  :D

Lee

355
Thanks for posting the source, I am building up quite a nice collection now   =D

I am basically using them for learning purposes in how GLB works or how to achieve something in GLB. Types (as in functions in types etc) were one of my biggest problems but thanks to source posted on this forum & looking at how others have done it & why they did it that way has helped tremendously.

I started programming games on a ZX80 all the way up to an Amiga but when I switched to PC's many years ago writing tools/utils/apps basically took over & getting my mind back in track for games programming is taking a while (prob due to age  :D) but I will get there.

There are a few projects that I have done which have been halted/abandoned due to losing track or going in the wrong direction but all of them have served a purpose & have learnt a lot from them so they wasn't a waste of time.

Lee


356
I've uploaded a video of your spiral thingy code with added polyvectors and trailbacks. Click here to see it. :)

I like that a lot, even though it wants me to throw in the towel programming wise  :sick:

Lee

357
GLBasic - en / Re: Flashing white effect
« on: 2012-Feb-28 »
I remember seeing a post on the forum once talking about changing the texture coords in polyvectors to display a different part of the bit map, could you not double the size of your bitmap by adding a pure white block next to the main sprite like this, bad ascii art incoming  :D

+-------------+-------------+
|                  |                 |
| normal      |  white       |
| sprite        |  sprite      |
|                  |                 |
+-------------+-------------+

I'm assuming that's the effect you are after if not sorry  :noggin:

Lee

358
GLBasic - en / Re: Array speeds
« on: 2012-Feb-28 »
Thank you hardyx for that, very much appreciated as I would not been able to add the bits you posted without some serious headaches, like I said my C++ is far from great but I managed to get it to work by looking at the compile errors & hit & miss additions  :D

This was the code I ended up with

Code: [Select]
#include <stdio.h>
#include <time.h>

// put ordering functions here
//.....
const int g_n = 250;
float TestData[g_n][g_n][g_n];

inline void column_ordered()
{
   for (int k=0; k<g_n; k++)
      for (int j=0; j<g_n; j++)
         for (int i=0; i<g_n; i++)
            TestData[i][j][k] = 0.0f;
}

inline void row_ordered()
{
   for (int i=0; i<g_n; i++)
      for (int j=0; j<g_n; j++)
         for (int k=0; k<g_n; k++)
            TestData[i][j][k] = 0.0f;
}


inline clock_t GetTime() {
  return clock();
}

int main()
{
  float coltime;
  float rowtime;
  clock_t timeinit;

  timeinit = GetTime();
  column_ordered();
  coltime = GetTime() - timeinit;

  timeinit = GetTime();
  row_ordered();
//  clock_t
  rowtime = GetTime() - timeinit;

  printf("Columns time: %.3f tics\n", (double)coltime);
  printf("Rows time: %.3f tics\n", (double)rowtime);

  return 0;
}

I presume I done right as it compiles in GCC & executes,  also I take it that 1 Tic = 1ms?

The results where like the ones from the book in that rows where quicker than columns

Columns time: 378.000 tics
Rows time: 40.000 tics

GLB results
Columns time: 157.785
Row Time: 374.704

As you can see quite a different ratio between columns vs rows.

359
GLBasic - en / Re: Array speeds
« on: 2012-Feb-27 »
This was his original code

Code: [Select]
const int g_n = 250;
float TestData[g_n][g_n][g_n];

inline void column_ordered()
{
   for (int k=0; k<g_n; k++)
      for (int j=0; j<g_n; j++)
         for (int i=0; i<g_n; i++)
            TestData[i][j][k] = 0.0f;
}

inline void row_ordered()
{
   for (int i=0; i<g_n; i++)
      for (int j=0; j<g_n; j++)
         for (int k=0; k<g_n; k++)
            TestData[i][j][k] = 0.0f;
}


& his results

Column Ordered=2817 ms   Row Ordered=298 ms

There is no mention of the cpu used but prob P3 or an early P4, the compiler was Visual C++ .net.

His findings are like you said
Quote
In many languages row data are contiguous in memory
but as you can see mine were the opposite & column order was faster. How to convert the C++ into something I can compile & run in GCC or Visual C++ express that I have is beyond me at current as do not have that much knowledge of C++, just enough to pick some parts out  :D

Lee
 

360
FAQ / Re: Possible to compile for Mac Store?
« on: 2012-Feb-27 »
I will try doing things one at a time, for example just set the path & see what happens then try the env variables 1 at time & see what breaks it.

Lee

Update:

All sorted now, the problem was with the "GCC_EXEC_PREFIX" env variable, it was needed with BlitzMax in the past but no longer required. However, BlitzMax does not like the current version of MinGW so it has been duly wiped from my machine  :D

Pages: 1 ... 22 23 [24] 25 26 ... 36