Main Menu

Recent posts

#91
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - September 02, 2023, 08:51:46 PM
yeah, i needed to go through a bit of maths to find the collision.

full method:
> find skew line minimum distance between the camera ray and cylinder direction ray (direction cylinder is standing)
   > this gives the minimum distance between the 2 rays where a line is perpendicular to both rays
   > also gives this perpendicular lines as a vector
> find point on the camera ray where the minimum distance is located
   > turn the cylinder direction ray into a plane so it passes through the 'shared' perpendicular line
   > do camera ray to above plane collision check (gives location)
> find point on cylinder direction ray
   > turn the camera ray into a plane so it passes through the 'shared' perpendicular line
   > do cylinder direction ray to above plane collision check (gives location)
> calc intersection point on cylinder surface
   > find distance the camera ray is from the cylinder center vector, then calc remaining distance along the camera ray to the cylinder edge (gives distance like a shadow cast directly down from the ray)
   > calc angle the ray is from the cylinder center vector to get actual distance 'along' the ray
> check if collision is behind or in front of camera ray
> check if collision point is within the cylinder height
   > if inside height then calc surface point normal at this collision point on cylinder
   > if outside then calc both the upper cylinder face & lower cylinder face for a collision and calc the surface point normal at this collision point

this is why it took a bit to implement this into the code to show up on the renderer and shaded mode.
the good thing is it also detects a collision when i click on the screen to select the object in the editor.

i leart more about vector calculations doing this cylinder.

   stevmjon
#92
3D Development / Re: Build a basic 3D Render En...
Last post by kevin - September 01, 2023, 08:06:47 AM
 Hey Steve;

 
Quotejust added the cylinders to be able to be seen in 'fast shaded color mode' in the editor.

    That'd be a nice challenge given there's no nice easy mesh to render

     Looking good dude !

#93
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - August 31, 2023, 03:18:11 AM
just added the cylinders to be able to be seen in 'fast shaded color mode' in the editor.

also it can be selected in the editor too.

adding the cylinder was a good learning curve for me to better understand the maths behind 3D.
i like learning new things, it keeps the mind active.

   stevmjon
#94
Source Codes / 2d Stars Example
Last post by kevin - August 29, 2023, 06:23:42 AM
2D Stars Examples


 This is classic 2D (right to left) star scrolling routine.   This version is using parallel arrays for the stars coordinate and speed. There's a bunch of ways to do this; but here we're create filling our star with a random starting coordinate within the bitmap screen as well as give this star a random speed.

 This is integer only so it has fixed point precision, which just means we scale our values up by some fixed constant and anything bellow this becomes the fractional part and anything above it is the whole number part.  

 



[pbcode]

; PROJECT : Project1
; AUTHOR  :
; CREATED : 29/08/2023
; ---------------------------------------------------------------------

   AccBits = 2^16

   ScreenWidth =800
   ScreenHeight =600
   Count=25000

   Dim StarsX(Count)
   Dim StarsY(Count)
   Dim StarsSpeed(Count)

   For lp =0 to count
      StarsX(lp) = rnd(ScreenWidth*AccBits)
      StarsY(lp) = rnd(ScreenHEight-1)
      StarsSpeed(lp) = rndrange(1*AccBits,5*AccBits)
   next
      
   // -------------------------------------------
   do // Main Loop
   // -------------------------------------------

      cls

      lockbuffer   
         For lp =0 to count
         // Move the star to the left
         x=StarsX(lp)-StarsSpeed(lp)
         
         if X<0
            // wrap the X coordinate
            X=X+(ScreenWidth*AccBits)
            // give this star a new Y and speed
            StarsY(lp) = rnd(ScreenHEight-1)
            StarsSpeed(lp) = rndrange(1*AccBits,5*AccBits)
         endif
         // Store the updated X
         StarsX(lp)=x
         // draw it to the surface
         dot x/AccBits,StarsY(lp)
      next
      unlockbuffer   

      // flip the buffers
      sync
   loop spacekey()=true


[/pbcode]


 

   
   Learn to Code:

   https://playbasic.com


    Also see:  Electric 2D Stars

#95
Game Design / The Making of Karateka - Offic...
Last post by kevin - August 26, 2023, 05:52:20 AM
The Making of Karateka - Official Announcement Trailer | ID@Xbox Showcase

I was a huge fan of the original Apple II version of Karateka ...

Just like Elite, Karateka  includes concepts that would become common place in video games in later decades that were virtually completely foreign to audiences in the 1980's...   

Like most things I loved at the time;  I started to build my over version on the C64 back in the day.   Spending hours drawing a character on graphic paper than transferring it to the computer literally bit bu bit..  I got about as far as walk animation and the rest was a bridge too far my young coding mind...  but the game still impresses me today;  I suspect that comes from my understanding of the limitations that design to exists within...   but ultimately it's just a great classic game !







it really stuck out as a precursor of
everything that games would be
carotica Veronica

movie like experience I'd ever had in a
video game
love it it's so good
I didn't know who Jordan mcner was but I
wanted to be like Jordan mechner I was
in college we came home on vacation with
this new project that was starting
and we were taking karate lessons
the characters were not little sets of
pixels they in fact were fully formed
individuals they had personalities
rotoscoping is literally tracing each
frame to get a frame of Animation the
aesthetic and the motion was really
unusual for the time I knew how
important music was to tell a story but
I wasn't a musician so I turned to my
dad I said well why not have a series of
Beats that are tuned to notes

it understood that visuals mattered that
full motion mattered that human beings
mattered story is in most games
considered a mandatory aspect Jordan
predates all of that
erotica will stand the test of time as
one of the most elegant game experiences
that's ever been done it's amazing
thank you

#96
Source Codes / Re: Source Code To Draw Diagon...
Last post by kevin - August 25, 2023, 09:16:28 PM

   This is variation of the above code; except this version will read from a collection of pictures rather than just a random palette.

   You'll have to supply it a folder with a series of images named "frame01.png" , "frame02.png"  etc etc

   it assumes all the pictures
 
[pbcode]

   path$="-LOCATION-OF-FILES-FOLDER-"

   #include "freeimage"

   openscreen 1920,1080,32,1

   Screen=NewImage(GetScreenWidth(),GetSCreenHeight(),true)



   Dim Images(100)

   Bands=0
   for lp=01 to 100
      file$="Frame"+digits$(lp,2)+".png"
      if fileexist(path$+file$)
         image=LoadNewIMage(Path$+File$,2)
         Images(Bands) = Image
         drawimage image,0,0,false
         sync
         Bands++         
      endif
   next

   ;Bands=2
   BandWidth=GetScreenWidth()/Bands

   dim Palette(Bands)
   dim IMagePOinter(Bands)
   dim IMageModulo(Bands)

   
   for lp =0 to Bands
      Palette(lp) =rndrgb()

      Image=Images(lp)
      rendertoimage Image
      lockbuffer
         ThisRGB=point(0,0)
         IMagePOinter(lp)   =getimageptr(image)
         IMageModulo(lp)   =getimagepitch(image)
      unlockbuffer

   next   
   rendertoscreen



   ScreenWidth   =GetScreenWidth()
   ScreenHeight=GetScreenHeight()
   

   rendertoimage Screen
   lockbuffer
   ThisRgb=point(0,0)

   for ylp=0 to ScreenHeight-1
      OffsetY=mod(Ylp,BandWidth)

      DiagX = BandWidth-OffsetY

      ColourY=mod(Ylp/BandWidth,Bands); Xor Colour

      for xlp=0 to  ScreenWidth-1

            //  compute the grid along x axis
            GridX=Xlp / BandWidth
            ColourX =mod(GridX,Bands)

            //  Add the X and y grid positions to find
            // which band we're in with the palette
            Colour = mod(ColourX+ColourY,Bands)

            //  compute the Xpos to side what side of the
            //  triangle we're in; if we're higher then
            // we're in the next band of colour
            Offset =mod(xlp,BandWidth)  > DiagX
            Colour =mod(Colour + Offset , bands)


            //
            Ptr =IMagePOinter(Colour)+(xlp*4)
            Ptr+=IMageModulo(Colour)*Ylp
   
            ThisRGB =peekint(Ptr)
            dotc xlp,ylp,ThisRGB

      next      
   next
   unlockbuffer
   rendertoscreen
   drawimage Screen,0,0,false
      
   Sync
      
   FreeImage_SavePNG Path$+"Output.png",Screen

   waitkey
   waitnokey
   

[/pbcode]


  Walking Out the bush - Time Lapse
 

#97
Source Codes / Source Code To Draw Diagonal B...
Last post by kevin - August 24, 2023, 10:04:51 AM
  Source Code To Draw Diagonal Banding


  This routine generates a colorful diagonal pattern with bands of colors across the screen. The colors in the bands change based on the position within the diagonal pattern, creating an interesting visual effect.


  This code generates a captivating visual display by enveloping the screen or any designated surface with an array of randomly colored bands. These bands are meticulously aligned to a grid-based pattern. The algorithm determines the grid tile that each pixel corresponds to, and subsequently calculates its specific displacement within that grid. Conceptually, this process involves assessing whether the point falls within the boundaries of a right-angled triangle for every scan line. While this methodology might initially seem intricate, no simpler alternative method has presented itself at this juncture


[pbcode]

   BandWidth=100

   Bands = 10   

   dim Palette(100)
   for lp =0 to Bands
      Palette(lp) =rndrgb()
   next   

   ScreenWidth   =GetScreenWidth()
   ScreenHeight=GetScreenHeight()
   
   
   lockbuffer

   for ylp=0 to ScreenHeight-1
      OffsetY=mod(Ylp,BandWidth)

      DiagX = BandWidth-OffsetY

      ColourY=mod(Ylp/BandWidth,Bands); Xor Colour

      for xlp=0 to  ScreenWidth-1

            //  compute the grid along x axis
            GridX=Xlp / BandWidth
            ColourX =mod(GridX,Bands)

            //  Add the X and y grid positions to find
            // which bandwe're in with the palette
            Colour = mod(ColourX+ColourY,Bands)

            //  compute the Xpos to side what side of the
            //  triangle we're in; if we're higher then
            // we're in the next band of colour
            Offset =mod(xlp,BandWidth)  > DiagX
            Colour =mod(Colour + Offset , bands)

            // draw it
            dotc xlp,ylp,Palette(Colour)

      next      
   next
   unlockbuffer

   Sync
   waitkey
   waitnokey
   
      
[/pbcode]


  Learn To Code , 2D , Grid, Diagonal Bands
#98
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - August 23, 2023, 02:28:46 AM
i have added the cylinder to the renderer now, yay.

i just need to adjust it so it registers height. the cylinder is currently infinite in height, lol.
getting this routine added took a lot more than i thought to calculate.
now i know why they stick to spheres and planes.

after i get the cylinder height done, i will add it to fast render view, so it shows up in shaded color mode in the editor.

   stevmjon
#99
Source Codes / Re: Simple particle library
Last post by kevin - August 16, 2023, 09:24:53 AM
  PlayBASIC - Particle LIbrary Demo

 This video shows fire effect created using DarkX's particle library for PlayBASIC from way back in 2009.  


 



 Related Examples:

     -  PlayBASIC Vector Blast Processing (2023-06-23)

      - Alpha Particles (Project pack example)



 Source Code

 Attached bellow
#100
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - August 09, 2023, 02:29:52 AM
just excited to share a screenshot of my progress.
i have just added cylinders in wireframe mode.

i now need to have them visible in the render itself, which is next.
i already know how to calculate this, just need to code it.

at the moment i am keeping all the code to see the objects mathematically, rather than using polygons. this way the objects stay high resolution when rendered.

   stevmjon