News:

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

Main Menu

Recent posts

#11
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - March 12, 2024, 07:20:59 AM
thanks kev. glad you like it.

i didn't originally intend for the program to get this big. been workin on it for about a year now.
not sure if i should add more or start a new project?

i was thinking of re-writing this with a better set up, as i didn't know what data needed to be shared.
a lot is copy/paste with an edit. it is getting harder to add to the code, as i need to adjust it in many area's, so a re-write would make it smaller and easier to grow.

i was thinking of a 3D editor with all polygons, so you can make any shaped object you like?
there is already free stuff that does this, but i am doing this for the challenge and the fun of it.

anyway, if there is any bugs let me know, or any new idea's i can add.

   stevmjon
#12
3D Development / Re: Build a basic 3D Render En...
Last post by kevin - March 11, 2024, 09:22:15 PM

  Brilliant mate !
#13
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - March 11, 2024, 07:10:01 PM
well, time for another update to v0.54 March 2024.

this update was delayed because i wanted to add more tools & features requested by Kev.
i also fixed several bugs i found too.

Features :
> 'array' tool : this lets you clone an object in a grid pattern (good for walls, decking etc).
> 'clone' tool : this lets you clone an object in a given direction (good for stairs and above also).
> 'save / load' files : all the shape types are now supported, and the name of a loaded file appears in the screen title (top).
> 'panels' : a panel pops up with settings for different tools. it can be moved around the screen by click & hold the title. it also remembers the last settings used.
> 'panel values' : made sure that small movements of the mouse always give at least 1 integar value (it used to give zero)
> 'solid mode' : this is a new draw mode for the objects. the objects are converted to polygons and drawn solid. the draw order is artists render method so is far - near order.
  * NOTE: the advantage is the objects are drawn solid and are drawn fast. some polygons may 'pop' in front/behind others because i am using artist render method.
> 'more shapes' : there is ball , cylinder & box shapes(new). all shapes can be rotated & scaled.
> 'render modes' : there is multiple smaller render sizes for a quicker view. 100% , 50% , 25% .

i have also included a save file with this demo with the walkway object i made with this program.

   enjoy, stevmjon
#14
Source Codes / Number of Good Pairs - Leetcod...
Last post by kevin - March 10, 2024, 10:40:45 PM
#1512. Number of Good Pairs

Given an array of integers nums, return the number of good pairs.

A pair (i, j) is called good if nums == nums[j] and i < j.

 
Example 1:

Input: nums = [1,2,3,1,1,3]
Output: 4
Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.

Example 2:

Input: nums = [1,1,1,1]
Output: 6
Explanation: Each pair in the array are good.

Example 3:

Input: nums = [1,2,3]
Output: 0

 

Constraints:

    1 <= nums.length <= 100
    1 <= nums <= 100



    Here's  solution in PlayBASIC.    It breaks down into a two pass solution,  Using an array to map the number of values that have collisions (pairs) and then tally those up.   I feel like this could be solved it in one pass,  can you do it ?   :)



[pbcode]


 Test$="1,2,3,1,1,3"
; Test$="1,1,1,1";
 ;Test$="1,2,3"


 print "Test:"+Test$

 // Split this split into an numeric array
 dim Numbers(0)
 Count=Splittoarray(Test$,",",Numbers())
 


 //  count unique values   
 dim Values(10)
 for lp=0 to Count-1
      ThisValue = Numbers(lp)
      Values(ThisValue)++
 next


 // compute total good pairs
 TotalPairs = 0
 for lp=0 to GetarrayElements(Values())
       Count = Values(lp)       
      do   count>0      
         count--
           TotalPairs+=(Count)
      loop
 next
 
 print "Good Pairs:"+str$(totalPairs)
 

 sync
 waitkey


[/pbcode]



#15
General Support / Please use bigger fonts in thi...
Last post by piamoo - March 02, 2024, 02:44:41 AM
Hello!

Just like the fonts of this popular forum: https://www.syntaxbomb.com/forum/

Thank you very much!
#16
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - February 09, 2024, 08:03:28 PM
good idea kev.

i can add a new preview mode that is 'solid mode' where all the objects are replaced with a PB shape.
this will stop the delay that the shaded modes have each time when movement stops.

i will delay the next release a bit more to implement these new ideas. if you have any more let me know and i will add them.

i have also added a new array tool too. i will post a pic when i get the panel for it done.

   stevmjon
#17
3D Development / Re: Build a basic 3D Render En...
Last post by kevin - February 07, 2024, 07:20:12 AM
  Cool!!!  

 Another thing  I was thinking about was possibly trying a dithering style patterns for the filled preview modes too.   So the user can get a sense of it while something is moving without drawing the while thing every refresh


#18
3D Development / Re: Build a basic 3D Render En...
Last post by stevmjon - February 04, 2024, 11:52:13 PM
kev, i just added a tweaked version of what you suggested with the preview render resolution.

instead of drawing the screen in stages as you suggested, i decided to draw a smaller preview screen size with all the detail in it. still draws so much faster too.
100% = 114 seconds
50% = 28 seconds
25% = 7 seconds

great idea for this suggestion kev. now i don't have to sit thought slow render times, lol.

i will post a new demo very soon too. i now have all the routines in for boxes, and i am now just setting up a nice default scene to view. i wanna get a bit creative with the boxes.

   stevmjon
#19
Beginners / Re: Help with platformer
Last post by kevin - January 30, 2024, 08:52:07 PM
 I think with these type of collisions it best to step through the possibles then  choose the best option.  in sliding collision recursion is generally used so be find the first collider (if any) then compute the re-positioned (slid) movement vector..  Then repeat this process until no collisions occur.

It's worth trying to handle as there's always situation were a character will slide through wall / corner given the right circumstances.   Speed runners love those kinds of bugs, but players hate them. 
#20
Beginners / Re: Help with platformer
Last post by kevin - January 29, 2024, 08:24:03 PM

  There's various 2d platformer examples posted and even a few in the PLayBASIC examples..  But here's the Mario demo from 2009

  Mario Demo