Welcome, Guest. Please login or register. Did you miss your activation email?

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.


Topics - Recoil

Pages: [1]
1
DotNet / SFML on Linux with MonoDevelop
« on: February 16, 2020, 06:53:53 pm »
I recently moved from Windows 7 and Visual Studio to Linux Mint and have been trying to get projects working in MonoDevelop, but kept running into a whole bunch of issues so I decided to just try to start from scratch and pull in what I previously wrote later.

I should note that I have diligently tried following advice on previous posts regarding setting up config files to point to .so files from .dll libraries, but was not successful as the error said:

Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. - which I cannot find.

This is what one of my config files loo like:
sfml.graphics.dll.config
&#38;#65279;<?xml version="1.0"?>
<configuration>
    <dllmap os="windows" dll="csfml-graphics-2" target="csfml-graphics-2.dll"/>    
    <dllmap os="linux" dll="csfml-graphics-2" target="libcsfml-graphics.so.2.2"/>
</configuration>
 

So I am trying to get a simple C# or VB.NET Hello World application up and running with MonoDevelop and SFML, yet keep running into issues with the references, either the .dll files pointing to .so files, or trying to use the SFML.NET package.  I have tried so many things it would be difficult to list them all and their errors trying to piece something together.

So I really hate to ask, but does anyone have a working hello world project they would be willing to share that works with MonoDevelop on Linux?

I am just so lost on getting anything working on this OS.

2
DotNet / Multi-threading SFML Render Window
« on: July 01, 2019, 04:00:30 pm »
I have a Render Window working that is used to test objects and text drawn to it.  That Render Window is in a class called Engine, that handles all the initializations, program loop, render window events, and disposing.

My Sub Main() initializes an Engine instance, and runs the Engines loop.  When I move or resize the Render Window the program freezes until I let the mouse go.  So now I need to multi-thread the SFML's already multi-threaded render window.  However, when putting the Engine's instance on a separate thread to initialize and run the program loop, I run into the same thing of freezing while I am moving or resizing the window.  This make sense as pretty much nothing has changed, and only forwarded the issue to a new thread, yet I am not sure where to handle the freezing issue at so when I move or resize the screen the program keeps cycling.

I'm not sure how good a code example will work in this instance, but it is VB code so as close to pseudo code as possible...

Main Module:
Module Test

    Public Enum State

        Initializing
        Running
        Stopped

    End Enum

    Private m_Engine As Engine
    Private EngineThread As Threading.Thread

    Sub Main()

        EngineThread = New Threading.Thread(AddressOf EngineStart)

        EngineThread.Start()

    End Sub

    Private Sub EngineStart()

        m_Engine = New Engine(True)

        m_Engine.Initialize()

        Do While m_Engine.EngineState = Engine.State.Running

            m_Engine.Run()

        Loop

        m_Engine.DestroyEngine()

    End Sub

End Module
 

Engine Class:
    Public Sub New()
    End Sub

    Public Sub Initialize()

        SetState()

        ResetClock()

        SetContextSettings()

        CreateNewRenderWindow()

    End Sub

    Public Sub Run()

        CalculateTime()             ' process timing stuff

        PrepareScreens()            ' set view, dispatch events, clear

        DrawStuffToScreens()        ' entities, gui, text

        PresentScreens()            ' display

    End Sub
 

The Render Window is already handling any window events, keyboard input, mouse actions, and joystick events by default, so I am not sure where, or how, to allow the program to continue to process while I am moving or resizing the window.  Is this just a default of using the SFML RenderWindow?

3
DotNet / Custom Shape with Texture
« on: June 26, 2019, 05:41:13 pm »
I'm trying to create the graphics for custom shaped buttons.

Currently I can draw a vertex array with 4 points to the screen and set the color of those points to get a solid color shape or gradient shape for a simple rectangular button.

I can even set a sprite from .png image to draw for the button as well.

Instead of drawing a vertex array, or a simple RectangleShape, I would like to draw any shape, and use a rectangle RenderTexture (or other texture), for that shapes texture.

For instance, if I draw a rounded rectangle, I have to draw 5 attached rectangles (center, top, bottom, left, right), then draw a triangle fan at each corner.  I can set all the points to the same color for a solid color.  I can also set the center rectangle points and the triangle fan corner points to one color, and all the outside points to another color for a radial gradient.  However, I cannot apply a vertical or horizontal gradient effect from a rectangle texture over that set of vertices.


I'm not sure if what I am trying to achieve is clear, so I have attached a mock-up image showing what I want to do.  I'm merely looking for the logic of the best way to go about doing this.

4
DotNet / [Re-Solved] Layer lighting help
« on: June 13, 2019, 10:09:47 pm »
I'm revisiting my lighting code for my engine so it has a much better working effect.  All of the examples I have come across say to use a lightmap over the screen and set the blend mode to multiply.  I have tried using different "lightmaps" to see if mixing with the blending options helps but so far none of them seem to work correctly.  To save time I will omit the testing results that I have got using each one.

I had some initial success drawing a black png image over the whole screen and setting the blend mode to alpha, then for each light instance drawing a smaller blurred light image with transparent background, and the blend mode set to add on top of the black layer.  However, that isn't really providing the type of lighting effect I see done with other engines, so it's back to the drawing board and here to see if someone can help me with the logic behind my code.

This is the order I am drawing my layers to the render window:
Lower tiles
Player
NPC's
Upper tiles
Night layer (alpha blend)
Light layer (add blend)
UI

I am attaching the current light image I am using as well as the result using approx. 86% opacity.  When I set the opacity to 100% the black is fully black, and the lights are blurred fully white and I am unable to see underneath.  My goal is to be able to increase the black to 100% to hide objects outside of the light sources, while being able to see the characters and map under the lights.

If it will help I can add the list of results I have gotten using different lighting images and blending modes.

5
Graphics / SFML and Game time
« on: May 26, 2016, 04:09:14 pm »
Sorry if this post is a bit vague, it has been very difficult to wrap my head around everything involved.

For starters:
Language - VB.NET...yes, I already know -_-
SFML - Posting these questions here because the graphics engine plays a key part in my maths.
Farseer - Unable to locate examples that will translate into vb.net
Box2d - I found 1 C# example that I was able to get translated, but am unable to grasp how to set the objects sizes and positions...let's pretend that I don't program as a 9-5, and/or am an idiot.

Okay, with that out of the way I have been transitioning a top down game engine to be able to support 2D side-scrolling.  To test I have been simply trying to get a ball to have visually accurate physics in a testbed application.  It didn't take very long to determine that I would need to incorporate a physics engine for the simple purpose of providing (any) objects realistic physics...and since I have been unable to locate a solid example in vb.net, and trying to get the above engines to work properly is beyond the scope of my understanding, I am simplifying things and building my own engine.

Change in Time, or Delta Time, is one thing that has come up in just about every physics equation that I would have to use to calculate falling/collision/velocity.  The way I am using SFML in my application has a large effect on the time that I need to calculate:

Private Sub InitializeEngine()

        ' Request a 24-bits depth bufer when creating the window.
        Dim contextSettings As New ContextSettings()
        contextSettings.DepthBits = 24

        ' Create main window.
        _testbedWindow = New RenderWindow(New VideoMode(800, 600), "SFML Graphic Controls Testbed Application.", Styles.Default, contextSettings)
        _testbedWindow.SetVerticalSyncEnabled(True)
        _testbedWindow.SetFramerateLimit(60)

    End Sub
 

I understand what SetFramerateLimit does, but when it is turned off it seems pointless since SetVerticalSyncEnabled keeps my FPS around ~60.  However,  just found out that is most likely due to the refresh rate of my monitor, and someone with a 75hertz refresh rate would have a higher FPS without the limit.  Perfect, and I understand it...

Now in my game loop I am calling this every loop:
        ' Reset to keep all timers in sync.
        _currentTick = Environment.TickCount

        ' Counts time every loop, then updates the FPS every second.
        If _currentTick - _timeCount >= 1000 Then
            _fps = _fpsCount
            _fpsCount = 0
            _timeCount = _currentTick
        Else
            _fpsCount += 1
        End If
 

Great...every loop add 1 to the _fpsCount until it reaches 1000 ticks, then update my _fps value that will display on my screen...Check!

In order to achieve realistic physics, I have to get the Change in Time between each game loop.  Since I am already returning the Environment.TickCount every loop, what is the most practical, and most accurate, method to produce the time between the frames?  I could have a Delta_Time variable setup, but I honestly have no clue using SFML the way currently am to return a value to apply to it, that can be applied to the physics equations I have found with my google-foo.

Please not I'm not looking for code, just the logic behind how this is supposed to work properly.  If there is anything that I have overlooked, please let me know.

6
General / .NET Physics for SFML?
« on: May 22, 2016, 04:35:41 am »
I have been tinkering around with stuff for my game engine and I am currently working on a small test project with a ball that has various physics aspects applied to it, such as rolling/bouncing/collision/gravity/etc...

Using the best google-foo I could master I set out searching for everything related to making this stuff happen.  Collision with the walls are working, and I can get it to bounce, and roll with rotating the ball shape.  Gravity, not so much.  I wanted to have a jump effect, which kinda works, but it only works on the bottom of the screen.  If I made platforms to jump to it is not going to work.  It seems there is a lot more to a few simple lines of code to make simple things happen.

So I came across the idea of using an existing physics engine...but it also seems I will have to recreate this wheel as well, because there is virtually nothing for vb.net, and everything I could find for C# uses XNA or Mono.  Because I am already comfortable working with SFML I really don't want to switch to anything else.  However, before I even set out on this journey I have to find out if anyone here who uses C# (because I am probably the only one using VB.NET) has a compatible engine they use with SFML?

I came across Box2d already, but the C# port of it was from 2008, and the examples I could never get to even work.  That project is now dead.  The good news is the devs moved on to making Farseer...unfortunately the examples are for XNA and Mono -_-

So I am reaching out to get some ideas.  I don't want to make one from scratch, the maths are just to difficult for me to understand.  Any ideas would be much appreciated.

7
I guess I was posting about this in the wrong forum.  Here is what I was running into with the gradient issue:
http://en.sfml-dev.org/forums/index.php?topic=20324.0

So that is fixed though, and I was able to piece together how to do either a vertical or horizontal gradient for my button control.  TBH, I have been so unsuccessful getting any of the control libraries that are out there working with VB.NET, because there are virtually no tutorials.  Most of the tutorials and documentation I have found has been in C++, and very limited info in C#.

Anyways, I'm making some progress on a custom control library.  There are a few bugs I am still working out, and some functionality missing, but so far I am okay with what I have been able to come up with on my own:


I would like to extend this though, mainly the graphics for the buttons.  Still working out how to do it, but it can (originally did) show images for the buttons.  So, with the above issue solved for the gradient, I can make the gradient vertical or horizontal.  I would like to see about extending this to a radial gradient, and hopefully having a rounded rectangle.  I ran across this looking for an idea for a rounded rectangle shape:
https://github.com/SFML/SFML/wiki/Source%3A-Draw-Rounded-Rectangle

With my limited skills, I made a failed attempt to convert that to VB.NET, and I get a flag with really weird half circles on the sides of the flag.  I think it best I try to make something on my own instead, that way I may be more able to understand how it actually works.

I would like some help understanding how a rounded rectangle shape should be made?  I was able to find a limited number of docs online in C++ that suggests using triangle fans...but those are way over my head, and I was lucky to figure out how to make a rectangle on my own.

Second, instead of using either a vertical or horizontal gradient, I would like to be able to use a radial gradient.  The same documentation I found on this also dealt with using triangle fans...which doesn't help when it is C++.

I'm not necessarily looking for code, but it would be appreciated.  But if someone can provide me a few ideas how to achieve a radial gradient effect as well as a rounded rectangle effect for a custom button control I would really appreciate it.

Note: I am also after some general ideas for being able to skin these controls, like selecting a color scheme and it apply to every customizable aspect of that control, which would make things easier instead of setting every color for every object on the control.  Another thing I am looking for ideas on is the best approach to allowing the use of gradients, as well as custom images.  The only thing here I can think of is on the drawing sub for the control (If ImgTexture = Nothing Then DrawGradient, Else Draw ImageTexture)...but there has got to be a more logical approach that I have overlooked.

I really appreciate any help or ideas you guys can give me...Thanks!

8
DotNet / [VB.NET] Gradient Rectangle - [SOLVED]
« on: May 15, 2016, 03:26:29 am »
Currently I have a rectangle shape I am using for a control image.  It looks flat so I would like to make it gradient instead.  So far I have pieced together this, but I'm pretty certain that the coordinates are wrong for my rectangle...New Vector2f requires 2 coordinates:

Dim col1 As New SFML.Graphics.Color(102, 102, 255, 255)
        Dim col2 As New SFML.Graphics.Color(0, 0, 255, 255)

        Dim v1 As Vertex = New Vertex(New Vector2f(0, Me.Location.X), col1)
        Dim v2 As Vertex = New Vertex(New Vector2f(Me.Location.X, Me.Size.Width), col1)
        Dim v3 As Vertex = New Vertex(New Vector2f(Me.Location.Y, Me.Size.Height), col2)
        Dim v4 As Vertex = New Vertex(New Vector2f(Me.Location.Y + Me.Size.Height, Me.Size.Height), col2)

        Dim rectangle() As Vertex = {v1, v2, v3, v4}
 

I am unable to test that because I cannot do "target.Draw(rectangle())".  I tried inserting arbitrary values, but then VS says cannot convert the rectangle to drawable.

Hoping someone has an idea of how to draw a simple gradient rectangle.  Thanks.

9
DotNet / [VB.NET] Mouse events for custom drawn gfx controls.
« on: May 12, 2016, 03:02:35 pm »
Hey guys!  I ran into too many issues regarding lack of documentation for all of the SFML control libraries I found, so I set out to create my own that may work a bit easier for what I am doing.  I have created several generic controls that I would like to enhance and be able to throw in a dll and reuse with other projects. 

I am using a picturebox as my RenderWindow.  Currently I check the mouse events for that picturebox, and send them through to Rectangles that I have setup for the bounds of my drawn objects...this may sound simple, but it is often a very tedious way to get custom drawn controls from scratch to function properly, especially when I can have a dozen controls on the RenderWindow.  It would be so much easier if I could just set all the methods for the mouse events in the drawn object class itself, but I have tried adding handlers to these drawn controls with no effect when I try to use them.

Recently I found additional options for getting input in my application loop.

This can get mouse events specifically for my form:
        If WinForm.MouseButtons = (MouseButtons.Right) Then
            MsgBox("Right button pressed.")
        End If
 

This can get mouse events while the application is running, on my form or outside of it:
        If Mouse.IsButtonPressed(Mouse.Button.Right) Then
            MsgBox("Right button pressed.")
        End If
 

There is pretty much no way to determine if the mouse wheel is/has been scrolled though.  Regardless, these still are not proper ways to get my controls to function properly from the classes themselves.  Over the last few days I have been able to piece together a basic understanding of making the events work from my control classes, but with the SFML documentation in cpp, and very few examples in C# that will not port to VB.Net, I am stuck on making any progress.

I feel like I am very close to making these work as intended, so I am hoping fresh eyes may be able to point me in the right direction.

10
Graphics / Clipping [VB.NET]
« on: June 19, 2015, 12:22:42 pm »
I am able to draw a sprite to the screen and change the opacity values to look like night and day.  Not I am trying to achieve lighting effects for various sections of the screen that will not be affected by the dark overlay.  I'm trying to determine how I can clip the second sprite with the first CircleShape so I will have a start on a dynamic lighting effect.

Dim tmpLight As New CircleShape(300)
tmpLight.Texture = New Texture(LightGfx)
tmpLight.TextureRect = New IntRect(LightGfxInfo.Width / 2 - 150, LightGfxInfo.Height / 2 - 150, 300, 300)

tmpLight.FillColor = New SFML.Graphics.Color(255, 255, 255, 255) 'CurrLevel)
tmpLight.Position = New Vector2f(0, 0)
GameWindow.Draw(tmpLight)
 

Dim tmpSprite As Sprite
tmpSprite = New Sprite(NightGfx)
tmpSprite.TextureRect = New IntRect(0, 0, frmMainGame.GameScreen.Width, frmMainGame.GameScreen.Height)

tmpSprite.Color = New SFML.Graphics.Color(255, 255, 255, CurrLevel)
tmpSprite.Position = New Vector2f(0, 0)
GameWindow.Draw(tmpSprite)
 

I do not see any way that I am able to clip the Sprite by the CircleShape.  I would really appreciate a suggestion on a method to achieve this.

11
Graphics / VB.NET - change alpha level on sprite?
« on: June 13, 2015, 02:07:19 am »
So I have seen this: http://www.sfml-dev.org/tutorials/2.1/graphics-sprite.php

I am able to set my colors like this:
tmpSprite.Color = SFML.Graphics.Color.Green
 

I honestly do not understand how to be able to change it so I can have the 4 channel argb instead.  Does anyone have an idea?

Please let me know what other information would be helpful, in getting an idea...thanks.

12
Graphics / Drawing buttons
« on: June 10, 2015, 04:08:52 pm »
I have been drawing text with rectangles for buttons as a temporary solution just to get something up and running.  The rectangles would be used to check the location of the mouse on mouse up, mouse down, and mouse over subs.  This worked but looked horrid...

I started working on creating buttons to replace that.  On the mouse events it checks if the location contains the mouse, then turns on a global variable. (Mouse Move Sub)
        If InBank Then

            If BankLeaveButtonLocation.Contains(e.Location) Then
                If BankLeaveMouseDownButton = False Then
                    BankLeaveMouseOverButton = True
                End If
            Else
                BankLeaveMouseOverButton = False
            End If
 

Then I have to declare the image for the button.
    ' Bank Leave Button
    Public BankLeaveButtonGfx As Texture
    Public BankLeaveButtonGfxInfo As GraphicInfo
    Public TempBankLeaveButtonBitmap As Bitmap
    Public BankLeaveButtonLocation As Rectangle
 

Then I have to initialize the button graphics with the rest of the graphics.
        ' Bank Leave Button
        BankLeaveButtonGfxInfo = New GraphicInfo
        If FileExist(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT) Then
            TempBankLeaveButtonBitmap = New Bitmap(Application.StartupPath & GFX_PATH & BANKWINDOW_PATH & "BankLeaveButton" & GFX_EXT)
            BankLeaveButtonGfxInfo.Width = TempBankLeaveButtonBitmap.Width
            BankLeaveButtonGfxInfo.Height = TempBankLeaveButtonBitmap.Height
            _transcolor = TempBankLeaveButtonBitmap.GetPixel(0, 0)

            _memStream = New MemoryStream()
            TempBankLeaveButtonBitmap.Save(_memStream, ImageFormat.Png)
            BankLeaveButtonGfx = New Texture(_memStream)
            _memStream.Dispose()
        End If
 

When the panel is drawing, then drawing the button, I have to check what the global variable is first and set the Y position.
        Dim BankLeaveButtonOffset As Integer = 0
        If BankLeaveMouseOverButton = True Then
            BankLeaveButtonOffset = MouseOverOffsetY
        ElseIf BankLeaveMouseDownButton = True Then
            BankLeaveButtonOffset = MouseDownOffsetY
        End If
 

Then draw the button in my render loop.
        ' Bank Leave Button Background
        Dim windowLeaveButtonSprite As Sprite = New Sprite(BankLeaveButtonGfx)
        windowLeaveButtonSprite.TextureRect = New IntRect(0, BankLeaveButtonOffset, TempBankLeaveButtonBitmap.Width, TempBankLeaveButtonBitmap.Height / 3)
        windowLeaveButtonSprite.Position = New Vector2f((windowSprite.Position.X + TempBankWindowBitmap.Width / 2) - (TempBankLeaveButtonBitmap.Width / 2), ((windowSprite.Position.Y + TempBankWindowBitmap.Height) - TempBankLeaveButtonBitmap.Height / 3) - 3)
        BankLeaveButtonLocation = New Rectangle(windowLeaveButtonSprite.Position.X, windowLeaveButtonSprite.Position.Y, windowLeaveButtonSprite.GetLocalBounds().Width, windowLeaveButtonSprite.GetLocalBounds().Height)
        GameWindow.Draw(windowLeaveButtonSprite)
 

Then I dispose of the TempBitmap along with the rest of the TempBitmaps...All that is just drawing 1 button, and only list 1 event that it changes.

However, I have to have several buttons drawn on the screen at various times.  Ideally I should create a class, but I am lost on what I will need to do to accomplish this with what I am doing to draw them now.  Can someone help me figure out what to do?

13
Graphics / VB.NET Transparent RenderWindow
« on: May 24, 2015, 12:20:16 am »
I have no idea if what I am trying to do is even possible because I am just starting out using SFML with VB.NET.

I currently have a picturebox that displays an image.  I am trying to use a control, a panel in this instance with transparent backcolor, to display on top of the picturebox, with about 50% transparency so the picturebox's image shows through the panel.  The panel will have additional controls inside of it that I would like to make transparent as well, but for now I am just trying to turn the panel slightly transparent.
Here is my code so far:

Public ItemWindow As RenderWindow

Sub InitGraphics()

        ItemWindow = New RenderWindow(frmMain.pnlItem.Handle)

End Sub

Sub DrawInventory()

        ItemWindow.Clear(ToSFMLColor(frmMain.pnlItem.BackColor))

        ' add items here

        ItemWindow.Display()

End Sub

Public Function ToSFMLColor(ToConvert As System.Drawing.Color) As SFML.Graphics.Color

        Return New SFML.Graphics.Color(ToConvert.R, ToConvert.G, ToConvert.G, ToConvert.A)

End Function
 

This shows the backcolor of the parent form both controls are on...so that obviously is not it.  I have done some searches on the forum here, but there is not a lot of VB.NET that I have found, and I am probably searching for the wrong terminology.  I'm probably doing this wrong anyways.

I would appreciate a point in the right direction or a better idea of how to display a half-transparent control over an image.  Thanks.

Pages: [1]