News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Recent posts

#21
Beginners / Re: Help with platformer
Last post by stevmjon - January 29, 2024, 08:09:03 PM
hey scott

just made an edit that smoothes out the left/right tile collision. you can now walk into a tile without it rubber banding left/right.
you will also need to put in a safety check before reading arrays to make sure player or tile you are checking in inside world bounds, so you don't read array outside it's dimension (gives an error message).

keep growing the platformer.

  stevmjon
#22
Beginners / Re: Help with platformer
Last post by stevmjon - January 29, 2024, 05:55:42 PM
with platformers there is actually 2 main worlds you can create, or you can manually create one like what you have done.
you can create worlds using PB inbuilt commands. they have cameras, layers etc that handle sprite sorting and tile map drawing. there is 2 main types of PB inbuilt worlds where one does the collision detection with tiles for you as well as collision with lines, or the other draws everything but you handle tile collision yourself. i use this second method, because you can make your own custom sloped tiles.

i recommend using the PB inbuilt worlds because you can put tiles and sprites (characters etc) on different layers and even scroll different layers at different speeds, which gives an effect of depth. so foreground moves faster and background moves slower.
i have a small demo on the forums you could check out for idea's. i think it was called 'sloped tiles'? i also made a bigger demo called 'holly'. you are welcome to use the graphics i made too.

anyway, i like looking at what you code and will take a peek.

  stevmjon
#23
Chat / Re: Depaint JS
Last post by stevmjon - January 29, 2024, 05:23:54 PM
oh, cool. i remember this back in the amiga days.
#24
Beginners / Help with platformer
Last post by ScottieBro1 - January 29, 2024, 11:53:05 AM
I was wondering if someone could help me figure out the collision detection for someing like this.
I need it tighter code not showing nicely.
Scottie B

Give a hack!
Thanks
#25
Chat / Depaint JS
Last post by kevin - January 28, 2024, 09:00:08 PM

[plink]Dpaint in your browser[/plink]
#26
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - January 23, 2024, 04:41:34 PM
oh good idea kev.

i can set up different render modes like you suggest. i will add another drop down menu selection with these settings.
i could even allow to set a different camera screen size too, that is not locked to your current window size.
#27
3D Development / Re: Build a basic 3D Render En...
Last post by kevin - January 23, 2024, 08:24:43 AM

Was going to suggest this earlier but it'd be ncie to be able to set the render resolution.   so 1/2, 1/4, 1/8 resolution.     If the res is set lower the render still goes back and fills in successive levels of detail, just at those lower resolutions the initial pixel takes up like 2by2 , 4by4 or even 8by8  so the user can get a sense of the scene quicker and exit out if something needs to be tweaked
 
#28
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - January 23, 2024, 03:19:15 AM
well, i got the shadows & reflections to work now.
it is faster than the post above too.

above post = 192 seconds
this post = 114 seconds

i do have a few idea's to get it to render faster.
one idea is instead of testing every object per ray with the shadows/reflection routines (this causes slow down), i can use the 3D transformation stages to calc the scene like the ray (shadow/reflection) is the look direction of a camera then calc min/max values to test which object spans across the screen center? if yes then test this object only. this should save a lot of calculations.

more to do it seems, stevmjon

#29
Beginners / Re: Fire Effect
Last post by kevin - January 16, 2024, 08:26:37 PM
  A quick clean up,  but doing an average across the points around the current point is pretty costly.   You can reduce this ! Just think about how the filter is moving through the buffer.  

 I suggest picking through my older replies as unfortunately i'd just be repeating myself.

[pbcode]
X_Screen_Res = 640
Y_Screen_Res = 480

Color_Mode = 32
Screen_Type = 1

OpenScreen X_Screen_Res,Y_Screen_Res,Color_Mode,Screen_Type

Dim Buffer_1(X_Screen_Res,Y_Screen_Res)
Dim Buffer_2(X_Screen_Res,Y_Screen_Res)

Do
   
Cls

For X = 0 To X_Screen_Res - 1
   
   Buffer_1(X,Y_Screen_Res - 1) = Rnd(50) + 100
   Buffer_1(X,Y_Screen_Res - 2) = Rnd(50) + 100
   Buffer_1(X,Y_Screen_Res - 3) = Rnd(50) + 100
         
Next X

Hotspots = Rnd(40) + 10

For I = 0 To Hotspots - 1

   X_Rand = Rnd(X_Screen_Res - 2) + 1
   
   For Y = -1 To 1
      For X = -1 To 1
         Buffer_1(X_Rand + X,(Y_Screen_Res - 2) + Y) = 255         
      Next X
   Next Y      
         
Next I

For Y = 1 To Y_Screen_Res - 1
   Y_Minus1 = Y-1
   Y_Plus1 = Y+1
   
   For X = 1 To X_Screen_Res - 2

      X_Minus1   =X-1
      X_Plus1   =X+1
      
      Top_Left    = Buffer_1(X_Minus1   ,Y_Minus1)
      Top          = Buffer_1(X         ,Y_Minus1)
      Top_Right    = Buffer_1(X_Plus1   ,Y_Minus1)
      
      Left          = Buffer_1(X_Minus1   ,Y)
      Middle       = Buffer_1(X         ,Y)
      Right       = Buffer_1(X_Plus1   ,Y)
      
      Bottom_Left    = Buffer_1(X_Minus1   ,Y_plus1)
      Bottom          = Buffer_1(X         ,Y_plus1)
      Bottom_Right   = Buffer_1(X_Plus1   ,Y_plus1)
      
      Average = (Top_Left + Top + Top_Right + Left + Right + Bottom_Left + Bottom + Bottom_Right) / 8
      
      If Average <= 0 Then Average = 0
      
      Buffer_2(X,Y_Minus1) = Average

   Next X
Next Y

LockBuffer

   Seed = Point(0,0)

   Scaler# = (1/255.0) * 100
   For Y = 0 To Y_Screen_Res - 1

      For X = 0 To X_Screen_Res - 1
         FastDot X,Y,RGBFade(RGB(255,255,255),Buffer_2(X,Y) * Scaler#)
      Next X   

       Next Y
UnLockBuffer


text 10,10,fps()
   Sync

   CopyArray Buffer_2(),Buffer_1()

Loop

         
[/pbcode]


 #Version #2 - Pre computed Palette

[pbcode]


X_Screen_Res = 640
Y_Screen_Res = 480

Color_Mode = 32
Screen_Type = 1

OpenScreen X_Screen_Res,Y_Screen_Res,Color_Mode,Screen_Type

Dim Buffer_1(X_Screen_Res,Y_Screen_Res)
Dim Buffer_2(X_Screen_Res,Y_Screen_Res)

   
      Dim Palette(32000)
      Init_Palette()



for lp=0 to 10
   sync
   wait 100
next
   


Do
   
   Cls

   For X = 0 To X_Screen_Res - 1
   
      Buffer_1(X,Y_Screen_Res - 1) = Rnd(50) + 100
      Buffer_1(X,Y_Screen_Res - 2) = Rnd(50) + 100
      Buffer_1(X,Y_Screen_Res - 3) = Rnd(50) + 100
         
   Next X

   Hotspots = Rnd(40) + 10

   For I = 0 To Hotspots - 1

      X_Rand = Rnd(X_Screen_Res - 2) + 1
      
      For Y = -1 To 1
         For X = -1 To 1
            Buffer_1(X_Rand + X,(Y_Screen_Res - 2) + Y) = 255         
         Next X   
      Next Y      
         
   Next I

   For Y = 1 To Y_Screen_Res - 1
      Y_Minus1 = Y-1
      Y_Plus1 = Y+1
   
      For X = 1 To X_Screen_Res - 2

         X_Minus1   =X-1
         X_Plus1   =X+1
      
         Top_Left    = Buffer_1(X_Minus1   ,Y_Minus1)
         Top          = Buffer_1(X         ,Y_Minus1)
         Top_Right    = Buffer_1(X_Plus1   ,Y_Minus1)
      
         Left          = Buffer_1(X_Minus1   ,Y)
         Middle       = Buffer_1(X         ,Y)
         Right       = Buffer_1(X_Plus1   ,Y)
      
         Bottom_Left    = Buffer_1(X_Minus1   ,Y_plus1)
         Bottom          = Buffer_1(X         ,Y_plus1)
         Bottom_Right   = Buffer_1(X_Plus1   ,Y_plus1)
      
         Average          = (Top_Left + Top + Top_Right + Left + Right + Bottom_Left + Bottom + Bottom_Right) / 8
         Buffer_2(X,Y_Minus1) = cliprange(Average,0, 256 * 8 )

      Next X
   Next Y


   LockBuffer
      Seed = Point(0,0)
      For Y = 0 To Y_Screen_Res - 1
         For X = 0 To X_Screen_Res - 1
            FastDot X,Y,Palette(Buffer_2(X,Y))
         Next X   
      Next Y
   UnLockBuffer

   text 10,10,fps()
   Sync

   CopyArray Buffer_2(),Buffer_1()
Loop




function Init_Palette()
      Scaler# = (1/255.0) * 100
      for lp=0 to GetarrayElements(Palette())
         Palette(lp)=RGBFade(RGB(255,255,255),lp * Scaler#)
      next   
endfunction         

[/pbcode]


 



  Links:

   Array Wrapping / Filtering / Sampling Speed Ideas
   Palette Mapping
   Tutorial - A Crash Course In BASIC program Optimization




#30
Beginners / Fire Effect
Last post by ScottieBro1 - January 16, 2024, 12:03:44 PM
I have some questions maybe kevin could help.
To optimize this fast enough It has to be poked memcopy I think
as for color I hate not being able to get to color registers like I used to.
So not only is it slow I don't know how to add palette.

This needs optimizations for sure.

Any suggestions?

ScottieB