none
Simple physics in SmallBasic RRS feed

All replies

  • Nice example of simple method looking very realistic - even with relax_count=1 it works well (a little more springy) - I also like the way ignoring any recoil momentum in reduce_the_tension_in_the_system gives a realistic impression of friction or damping.  I prefer it without the make_sure_particles_is_inside_box.  Cool.
    Sunday, August 21, 2011 8:08 PM
    Moderator
  • One of the best physics made with small basic. Maybe someday someone can make small basic clone from one popular bird game...

    Smooth frame changing is just one of the problems in small basic.


    Sorry My Bad English
    Monday, August 22, 2011 12:45 PM
  • One of the best physics made with small basic. Maybe someday someone can make small basic clone from one popular bird game...

    Smooth frame changing is just one of the problems in small basic.


    Sorry My Bad English


    Thanks!

    I am experimenting (inspired by the Soko sample) to improve rendering using Shapes.

    It seems to give  a significant performance boost to draw the particles with the Shapes and just move them.

    However I am running into problems with the lines as I thought instead of Remove/Add pattern I use Move/Scale/Rotate pattern to achieve the same thing.

    The problem I ran into was that Zoom is limited from 0.1 to 20 and that Zoom also zooms the lines width (which just looks strange).

    Do anyone have any tips to do "fast" line drawing in SmallBasic?

    FS

    Monday, August 22, 2011 8:18 PM
  • Nice example of simple method looking very realistic - even with relax_count=1 it works well (a little more springy) - I also like the way ignoring any recoil momentum in reduce_the_tension_in_the_system gives a realistic impression of friction or damping.  I prefer it without the make_sure_particles_is_inside_box.  Cool.


    Yes lower relax_count gives a more "springy" look as lower relax count are not enough to bring the system back to a relaxed state. If enough iterations is given to all constraints to relax the system should be very stiff as it's only built from stiff stick and rope constraints.

    Btw the same technique allows for "simulation" of cloth in a way that make it look very believable.

     

    Monday, August 22, 2011 8:26 PM
  • As you say the movement, rescaling etc of line shapes is difficult and the rotation/scaling takes a bit of effort to do correctly, since these transformations are w.r.t. to original line bounding box centre (rotation and zoom) and original top left corner (move) - and then you also have the width effect you see (maybe not a big problem for your example where the scaling is not too far from 1).

    Simple example of line moving/scaling/rotating - Import NMF477 - Note this doesn't work well with SilverLight implementation.

    A nice method would be a Shapes.MoveLine where you just enter the new end point coordinates.  This could be a suggestion for the development in a future version, or you could write an extension in C#, but if you can do this, SmallBasic probably isn't the best environment to be working with - but others may be grateful!

    Monday, August 22, 2011 9:54 PM
    Moderator
  • Just FYI I refactored the code a bit to use Shapes. Doesn't work at all in the online version of smallbasic but works a bit better on desktop.

    http://smallbasic.com/program/?DNX794

    FS

     

    Tuesday, August 23, 2011 6:18 PM
  • Smoother,

    I created a small SmallBasic extension to move a line, it is inside a zip called ShapesExtension_v1.0.zip with the source project ShapesExtension_Source.zip (VS 2010 Express C#) here.

    It should be much faster, easier to use and doesn't suffer from the line width issue.

    Also the source could be used as a template to do other interesting things with shapes using extensions for anyone interested.

    Sample SmallBasic code using the extension:

    line = Shapes.AddLine(50,50,100,100)
    Program.Delay(1000)
    ShapesExtension.MoveLine(line,80,80,120,300)


    Tuesday, August 23, 2011 9:08 PM
    Moderator
  • Smoother,

    I created a small SmallBasic extension to move a line, it is inside a zip called ShapesExtension_v1.0.zip with the source project ShapesExtension_Source.zip (VS 2010 Express C#) here.

    It should be much faster, easier to use and doesn't suffer from the line width issue.

    Also the source could be used as a template to do other interesting things with shapes using extensions for anyone interested.

    Sample SmallBasic code using the extension:

     

    line = Shapes.AddLine(50,50,100,100)
    Program.Delay(1000)
    ShapesExtension.MoveLine(line,80,80,120,300)


     

    Hi. Thanks this inspired me to start building a SmallBasic wrapper around Direct2D for potentially pretty awesome graphics.

    So far I have support for gradients and shapes such as:

    FastWindow.CircularGradientBrush (GradientBrush, "Clamp", -0.25, -0.25)
    FastWindow.GradientStop(GradientBrush, 0, 1, 1, 0, 0)
    FastWindow.GradientStop (GradientBrush, 1, 1, 0, 0, 1)
    FastWindow.FilledEllipse("SunEllipse", GradientBrush, 1, 100, 150, 100, 100)

    Draws a circle with a Radial Gradient (makes it look like a sphere)

     

    Sunday, August 28, 2011 10:03 AM
  • What a coincidence. I just finished gradient support to my extension. Did you make your own wrapper for DirectX?

    I used LinearGradientBrush and RadialGradientBrush. Right now I am adding support for ImageBrush which allows use of textures.


    Sorry My Bad English
    Sunday, August 28, 2011 10:14 AM
  • What a coincidence. I just finished gradient support to my extension. Did you make your own wrapper for DirectX?

    I used LinearGradientBrush and RadialGradientBrush. Right now I am adding support for ImageBrush which allows use of textures.


    Sorry My Bad English

     

    I rely on CodePack from Micrsoft. http://archive.msdn.microsoft.com/WindowsAPICodePack.

     

    Sunday, August 28, 2011 11:54 AM
  • What a coincidence. I just finished gradient support to my extension. Did you make your own wrapper for DirectX?

    I used LinearGradientBrush and RadialGradientBrush. Right now I am adding support for ImageBrush which allows use of textures.


    Sorry My Bad English


    Btw in case you are a little bit interested: http://tinyurl.com/3pf9w4b

    Source: http://smallbasic.com/program/?CRT219 (but doesn't work with the library obviously) 


    Sunday, August 28, 2011 2:29 PM
  • My code:

    Stops[0]["color"] = "#FFFFFF"
    Stops[0]["offset"] = "0"
    Stops[1]["color"] = "#FFFFFF"
    Stops[1]["offset"] = "1"
    GameWindow.Show()
    E = GameControls.AddEllipse(250, 20, 200, 200)
    G = GameEffects.CreateRadialGradient(Stops, 1,1, "", "", "reflect")
    GameEffects.FillWithGradient(E, G)

    And result

    http://img687.imageshack.us/img687/2189/gradienttest.png


    Sorry My Bad English
    Sunday, August 28, 2011 6:23 PM
  • As you say the movement, rescaling etc of line shapes is difficult and the rotation/scaling takes a bit of effort to do correctly, since these transformations are w.r.t. to original line bounding box centre (rotation and zoom) and original top left corner (move) - and then you also have the width effect you see (maybe not a big problem for your example where the scaling is not too far from 1).

    Simple example of line moving/scaling/rotating - Import NMF477 - Note this doesn't work well with SilverLight implementation.

    A nice method would be a Shapes.MoveLine where you just enter the new end point coordinates.  This could be a suggestion for the development in a future version, or you could write an extension in C#, but if you can do this, SmallBasic probably isn't the best environment to be working with - but others may be grateful!


    Since you mention extensions; I've created a Direct2D extension for SmallBasic now and I think its pretty powerful. Is there a good place to share this extension for the benefits of others?

     

    Tuesday, August 30, 2011 8:39 PM
  • There is no formal place, usually just a zip uploaded somewhere (skydrive, mediafire etc) and a link to it put somewhere on this forum.

    Perhaps we should have a full list somewhere - the problem with forum threads is they can get swamped with replies.  Perhaps I will create a sticky thread for extension developers to post links to their extensions downloads and request other don't post there - and the developers just update their single post within this thread as they want.

    Also, after your rather impressive physics sim I have started writing an extension to integrate Box2D physics - so far just working out how to do it.  Very early test exe of the main features I want here.

    Tuesday, August 30, 2011 9:22 PM
    Moderator
  • I can provide a mirror if you want.

     

    Maybe we should write own simple programming language instead of making dozens of different extensions?

    For example I started making my own oscript  (language is very much like small basic but also has parameters for functions) many months ago but the hole thing get stuck with IntelliSense and syntax highlighting of Idle, but the compiler works.


    Sorry My Bad English
    Wednesday, August 31, 2011 11:54 AM
  • There is no formal place, usually just a zip uploaded somewhere (skydrive, mediafire etc) and a link to it put somewhere on this forum.

    Perhaps we should have a full list somewhere - the problem with forum threads is they can get swamped with replies.  Perhaps I will create a sticky thread for extension developers to post links to their extensions downloads and request other don't post there - and the developers just update their single post within this thread as they want.

    Also, after your rather impressive physics sim I have started writing an extension to integrate Box2D physics - so far just working out how to do it.  Very early test exe of the main features I want here.


    I think a sticky extension thread sounds like a good start. I will check your box physics but it's getting late here ;).

    For what its worth I put the binaries here: https://skydrive.live.com/redir.aspx?cid=0993d1b0b96eb592&page=play&resid=993D1B0B96EB592!103

     

    FastWindow - A Direct2D extension for SmallBasic
    ------------------------------------------------

    Purpose:
    I think SmallBasic is great but its GraphicsWindow isn't very suited
    for smooth graphics rendering making it quite hard to do flicker free
    animation.

    FastWindow uses Direct2D to improve the graphics performance for
    Small Basic programs

    FastWindow is very much in beta and I am just probing the interest
    for such a small basic extension. Feedback to: fulesnabel@hotmail.se


      Simple.exe for a simple example on how it can be used
        (note this downloads some graphics therefore need internet connection)
      Simple.sb for the source code the sample exe.

    Because of its beta stage I haven't made an installer for FastWindow yet therefore:

    In order to use FastWindow:
    1. Locate the install folder of SmallBasic, usually C:\Program Files (x86)\Microsoft\Small Basic
    2. Copy Microsoft.WindowsAPICodePack.DirectX to the install folder of Small Basic
    3. Make a folder called lib in the install folder of Small Basic
    4. Copy SBFastGraphics.dll to the lib folder
    5. Copy SBFastGraphics.XML to the lib folder
    6. Start small basic
    7. Load Simple.sb sample
    8. Run (hopefully it works)

    Have fun.

    Wednesday, August 31, 2011 10:15 PM
  • There is no formal place, usually just a zip uploaded somewhere (skydrive, mediafire etc) and a link to it put somewhere on this forum.

    Perhaps we should have a full list somewhere - the problem with forum threads is they can get swamped with replies.  Perhaps I will create a sticky thread for extension developers to post links to their extensions downloads and request other don't post there - and the developers just update their single post within this thread as they want.

    Also, after your rather impressive physics sim I have started writing an extension to integrate Box2D physics - so far just working out how to do it.  Very early test exe of the main features I want here.


    Ok checked it. It looks cool, collision detection adds a large amount of realism. Is this http://box2d.org/ what you based it on? Did you ILMerge the Box2D code or did you just add the physics extension directly in the Box2D project?
    Wednesday, August 31, 2011 10:21 PM
  • Yes, it is a C# .Net implementation of box2D (called box2DX - I had to make some mods to the source to make it .Net 3.5 compliant).  The prototype was smallbasic library (for the graphics) on the Box2d test project exe.  Here is the first stab at a dll (Box2D inside smallbasic dll).  More testing, and refinement need, some functions not complete (the get position & getVelocity) yet others untested and I need some samples to test all the options and set some guidelines how to use it.  Any suggestions on the API (the options and how they are expressed to make it easy to use would be appreciated).

    Very simple sample Import HGG361 - very early test!

    PS, Add your extension (+source project if you are happy to) to the sticky list I added in this forum if you want they anyone interested can find it. 

    One the main ideas of SmallBasic is to encourage people to move on from SmallBasic (use it as a first stepping stone) and the using, then writing of extensions is a very good way to graduate to VB or C#, hence the small demo extensions I added to show the basic syntax.  These are not really ends in themselves, just a guide to start programming beyond SmallBasic for those that reach its limits and want more.

     


    Wednesday, August 31, 2011 10:45 PM
    Moderator
  • @Oskariok

    I am making my own language from VB and C#, called "CodeAwesomeness", based off of both VB and C, meant also like SB, for beginners. I already have some kind of intellisense working, but not good graphics. All the intellisense is for me is a blue rectangle with text inside, and no cool wheel animations like SB (don't know how to do resizing in SB).

     

    I am planning to release version 0.3 pretty soon, all from Small Basic website get it free! If you like Oskariok, you can see here. Sorry if there are some inappropriate posts, my friends do that (even though I ask them not to), and I don't know how to remove them. Please forgive me for any swears.

    [EDIT]

    Sorry, just remembered. I had previously found a bug or two in the intellisense, and so I am removing it from version 0.3. I may be adding it in 0.3.5 though!

     

    Also, versions 0.1, 0.1.4, 0.1.8, and 0.2 are all made in Small Basic, which makes it sort of slow (no offense, SB Team!), and so I switched to VB and C#. Is it also Oskariok that I use some of your library in 0.3? I had been meaning to ask for a while now. It's mainly for the image editing tools (which are really great!)

    Thanks


    ~~AirWaves!!~~
    Thursday, September 1, 2011 4:13 AM
  • @Airwaves

    What parts do you need? Data Extension isn't actually one file. it contains Data.dll, Data.Dialogs.dll, Data.Security.dll, Data.Core.dll

    The Small Basic extension is just all 4 dll files combined together.

     

     

     


    Sorry My Bad English
    Thursday, September 1, 2011 12:16 PM
  • I was actually just talking about some stuff in general, like the Picture tools. I guess I could go without them, but it would be nice. Thanks!

    ~~AirWaves!!~~
    Thursday, September 1, 2011 4:20 PM
  • @FuleSnabel,

    The direct2D graphics look really good.  The only issue is creating a simple API for the extension consistent with the existing graphical commands, (GraphicsWindow, Controls, Turtle and Shapes) and possibly integrating with the existing GraphicsWindow.  SmallBasic is primarily designed for young and starting programmers, with a deliberately small API.  Perhaps the SmallBasic developers will consider using Direct2D rather than Canvas as an underlying technology.

    Thursday, September 1, 2011 6:40 PM
    Moderator
  • @FuleSnabel,

    The direct2D graphics look really good.  The only issue is creating a simple API for the extension consistent with the existing graphical commands, (GraphicsWindow, Controls, Turtle and Shapes) and possibly integrating with the existing GraphicsWindow.  SmallBasic is primarily designed for young and starting programmers, with a deliberately small API.  Perhaps the SmallBasic developers will consider using Direct2D rather than Canvas as an underlying technology.


    I think I understand what the vision for SB is and I think SB is important and would like to help young kids to become young programmers. The reason for my Direct2D extension is that when I started (13 years old) I wanted to draw cool graphics. As I personally found some issues with drawing with GraphicsWindows (flickering and performance) I thought a Direct2D extension could be an alternative for SB programmers that want a tad more power without having to dig into C# with WPF, C++/CLI, Threads and Concurrent Queues.

    I am personally not overly concerned with that the API should be consistent with GraphicsWindow, however I want the API to feel like a SB API so that SB programmers feel familiarity. In order to achieve this I think the API should be robust (ie not crash when you do mistakes) and as simple as possible.. Yet I need the API to support fast and effecient updates of the view state (this was part of the problem with GraphicsWindow for me).

    I'm certainly interested in feedback on how to improve the extension.

    My own biggest concerns right now are:

    0. Is this something that SB programmers actually would find interesting? (If not I don't have to put in an effort :))

    1. Is the API expressive enough to allow aspiring SB programmers do cool stuff? (Not necessarily complete but enough)

    2. Is it easy enough to use?

    3. Is it robust enough?

    4. Is it easy to deploy? (in the current state this is a no for many reasons but this is something I am planning to do something about)

     

     

    Thursday, September 1, 2011 8:24 PM
  • @FuleSnabel,

    The direct2D graphics look really good.  The only issue is creating a simple API for the extension consistent with the existing graphical commands, (GraphicsWindow, Controls, Turtle and Shapes) and possibly integrating with the existing GraphicsWindow.  SmallBasic is primarily designed for young and starting programmers, with a deliberately small API.  Perhaps the SmallBasic developers will consider using Direct2D rather than Canvas as an underlying technology.


    I think I understand what the vision for SB is and I think SB is important and would like to help young kids to become young programmers. The reason for my Direct2D extension is that when I started (13 years old) I wanted to draw cool graphics. As I personally found some issues with drawing with GraphicsWindows (flickering and performance) I thought a Direct2D extension could be an alternative for SB programmers that want a tad more power without having to dig into C# with WPF, C++/CLI, Threads and Concurrent Queues.

    I am personally not overly concerned with that the API should be consistent with GraphicsWindow, however I want the API to feel like a SB API so that SB programmers feel familiarity. In order to achieve this I think the API should be robust (ie not crash when you do mistakes) and as simple as possible.. Yet I need the API to support fast and effecient updates of the view state (this was part of the problem with GraphicsWindow for me).

    I'm certainly interested in feedback on how to improve the extension.

    My own biggest concerns right now are:

    0. Is this something that SB programmers actually would find interesting? (If not I don't have to put in an effort :))

    1. Is the API expressive enough to allow aspiring SB programmers do cool stuff? (Not necessarily complete but enough)

    2. Is it easy enough to use?

    3. Is it robust enough?

    4. Is it easy to deploy? (in the current state this is a no for many reasons but this is something I am planning to do something about)

     

    Primoz128:

    I am planning to make a top down game. I am game making using Game Maker tools for 2 years and i know this. SB is perfect language for me, most human friendly ever.



    I love game design and game programing.
    • Edited by Primoz128 Friday, September 2, 2011 5:05 PM
    Friday, September 2, 2011 5:04 PM
  • The SBFastGraphics.XML file is not included in this package.  Can you please post?  Thanks!
    Tuesday, December 18, 2012 5:09 AM