dcsimg
Results 1 to 10 of 10

Thread: Experimenting With Game Ideas

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2018
    Posts
    131

    Experimenting With Game Ideas

    I am doing some experimenting with vb .net and wanted to make a program where people can make a design of different types of objects and images that you can save the file and load it in the player.
    Basically trying to make some type of game. I want to make a program where I have drag n drop things you can add to main display/game area. I don't know exactly what I am going for yet but was inspired by digital pinball designs. Programs like "Future Pinball" and "Visual Pinball".. Pinball seems like a big challenge to program a pinball table editor though, so I am trying to make something easier than this.
    One of the first things I would like to try to do is a few things..

    1: Make a picturebox that can play video and can be resized to anything the designer requires and place it anywhere on the form.
    2: To be able to save this file and reload it, and when reloaded, have it load the picturebox where the user has placed it.
    3: Same thing for an image..

    Will be adding more as it progresses and have more ideas.

    Hoping someone can help.

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    434

    Re: Experimenting With Game Ideas

    You need to start making your game shell.

    Sounds like the first thing is you will need a game board (picturebox) and a game object (class you make that is a rectangle you can drag and etc on the game board). The game object might resize by dragging handles, move on board by dragging, perform functions, interactions. May have a base object that is other objects. ie a rectangle is a rectangel, square, ellipse, circle, etc.

    Is the game to be animated ie things move automatically etc then you need a timer game loop.

    To save the game you can serialize your game data like classes etc and save that to disc file easily.

    You can use bitmaps images and or draw vectors images for characters etc.

    Here is a start on a basic shape object class:

    http://www.vbforums.com/showthread.php?588199

    Playing video gets hard depending what you mean exactly. I am not sure what you want that for if at all. Not a beginner project. Animated gifs are easier. What is your skill level? What is this for ... school? Impress yourself and your friends?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2018
    Posts
    131

    Re: Experimenting With Game Ideas

    Ok so I should use a form with a picturebox as the main play field or can I use just a form as the play field?
    I am assuming I want to use the picturebox because of the redraw?

    Yes things will be moving automatically when the ball or object hits other objects it will interact in some way with it.
    For example a target, flipper, bumper, character object etc..

    I see people doing graphics in different ways, GDI, Bitblt, XNA and MonoGame. Not sure about the last 2 options but have heard of GDI and have used bitblt in the past.
    I am going to assume that Bitblt is the fastest out of any of them considering that it's api so I would probably want to stick with that instead of GDI
    unless there are any specific reasons that I should use GDI?

    I am still at beginner level but motivated and driven by the ideas.
    This project is inspired by the digital pinball community, Future Pinball and Visual Pinball and just digital pinball in general I suppose but those 2 are my favorites.
    The community creates their own digital pinball tables and there are many that come out really awesome so I am inspired by that.
    The fact that people could design their own game boards/tables with the software is what I am trying to achieve with my project.

    So far I can play Audio via the MCI windows api and I think that Video should work just as easy, so that should be alright.
    I just need some starting goals. I am checking out what you said about adding shapes to the play field. I will keep looking into this and look for more examples.
    Wondering how I would go about making the ball roll around in 3D and how they get it to look so authentic with how the ball moves like a real pinball does.
    Hoping someone could help me figure this part out. I think it might be best to do this with Bitblt because of the speed of the api. I just do not know what I need to do to "get the ball rolling"

    Literally, LOL..
    Last edited by DreamWarrior77; Aug 9th, 2019 at 07:15 PM.

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,521

    Re: Experimenting With Game Ideas

    Well Bitblt would not be as fast as XNA or MonoGame, as those are libraries that will take advantage of the GPU of the graphic card for drawing.
    You mention Bitblt and GDI, but BitBlt is a function that is part of the GDI api.
    There was an extension made to the Windows Graphic API and that is referred to as GDI+. GDI+ is probably what you were referring to when you said GDI.

    The GDI+ methods in that API extension are what the graphical methods of the .Net framework use for graphic, so the normal drawing that you would do using a Graphics Object on the Form or Picturebox, or any other drawing surface in VB.Net or C# would be using GDI+.

    If you want to use the older GDI api, i.e. to use BitBlt, then you essentially have to suspend using the normal drawing methods, and get an .hDC for the control, then you can draw using bitblt and other GDI API methods. If you want to draw with "normal" .Net drawing commands, then you have to release the .hDC back to the control (or graphics object), and you can continue using the .Net drawing methods. You can't draw with both methods at the same time, but you can switch between the methods during a drawing session.

    If you want things to look smooth, and I assume the pinball community probably uses 3D drawing librarieGDIs like DirectX or OpenGL, or libraries that are based on those libraries, then you would want to use those libraries as well.

    You can create pinball games using GDI (bitblt, etc) or GDI+ (.Net drawing methods), but they will never look quite as smooth as something that can be sync'd to the hardware screen updates and take advantage of the advanced capabilities of the graphic cards.

    As for realistic movement, it will involve good physics calculations of things like accelerations, mass, friction, elasticity and inertia. I know of a couple of books on physics for game development and programmers, because I have those two books, but I've never had the patience to work through the math to try to build anything realistic. I've just used simple acceleration calculations and simple motion calculations based on speed and direction.
    Last edited by passel; Aug 10th, 2019 at 06:17 PM.

  5. #5
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    434

    Re: Experimenting With Game Ideas

    "Ok so I should use a form with a picturebox as the main play field or can I use just a form as the play field?"

    Yes well that is a good question. It can be done either way and it can be changed. I suggested the picturebox because then your can move that around and have other controls around the pbox like tool bars etc. You can easy arrange add and subtract as you go. Copy from one project to another etc.

    But it does not really matter at first I supose. Which do you want to do?

    Drawing is the same either way. We draw on a graphics object for the control/form. So its the same thing either way. You will see.

    "I am assuming I want to use the picturebox because of the redraw?"

    LOL. That sounds like a vb6 question!!!

    Not exactly. Drawing is the basically the same for all controls. Most have paint events called from the system that we use to draw at the correct time.

    By drawing in the paint events the image gets PERSISTED on the screen. There is no autoredraw in .net. Code that does the drawing is executed everytime the screen needs updating. There are several ways to do the drawing and persist it on the screen.

    "I see people doing graphics in different ways, GDI, Bitblt, XNA and MonoGame."

    In .net we use the GDI+. YOu can use apis like bitblt but they are no faster.


    "making the ball roll around in 3D"

    Well that is advanced. So you should realize you will need to make several hundred versions of every type of game and sound and animation and etc you can dream up and practice practice with it before you get really good at it and make what you describe.

    To start with you should go slow and simple. Learn one thing at a time. Get one thing running in a form and then add new things to it one at a time and debug it and get it running again one step at a time. Its fun to run and debug and add to it when it runs. Other wise you just have a frustrating bag of errors you cant debug.


    " I think it might be best to do this with Bitblt because of the speed of the api. "

    No, not really. You wont have speed issues on todays systems until you get much more happening. And you wont be able to do 3d at first. YOu may have to move to other than vb.net for 3d.

    For now you just need a simple something 2d.

    And on and on...

    Maybe make a pong game to start with? Or something simple that interests you. Lunar lander etc. Just moving a ball (circle) on the screen (form) using a timer loop is the first thing to do?

    So what have you done so far? Does that sound like what you thought? We can give you examples and of course there are thousands of things on the web to start making games etc.

  6. #6
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    434

    Re: Experimenting With Game Ideas

    Here is an example sort of like pinball for discussion purposes.

    There is a windows forms timer that makes the game loop. Each timer tick event the game objects are updated and the .invalidate statement makes the system call the paint event where we draw the entire screen all at once.

    With this basic shell you can get a fairly complex something going and have a lot of fun. Plenty of room for improvement as you go.

    The example makes the controls. Just cut and paste the code to an empty form. Change the form name as required.

    Name:  a3.gif
Views: 81
Size:  124.6 KB

    Code:
    Public Class Form1
        Private WithEvents timer1 As New Timer With {.Interval = 30}
        Private WithEvents StartBtn As New Button With {.Parent = Me, .Location = New Point(50, 10)}
        Private WithEvents AddBtn As New Button With {.Parent = Me, .Location = New Point(150, 10)}
    
        Private Structure Particle
            Public Position As Point
            Public Radius As Integer
            Public incrementx As Integer
            Public incrementy As Integer
            Public color As Color
        End Structure
    
        Private Particles As New List(Of Particle)
    
        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Text = "Particle Generator"
            DoubleBuffered = True
            StartBtn.Text = "Start"
            AddBtn.Text = "Add"
    
            'add the first particle to start
            AddParticle()
    
        End Sub
    
        Private Sub Form3_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
            e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
            e.Graphics.Clear(Color.Teal)
    
            For i = 0 To Particles.Count - 1
                e.Graphics.FillEllipse(New SolidBrush(Particles(i).color), Particles(i).Position.X, Particles(i).Position.Y, Particles(i).Radius * 2, Particles(i).Radius * 2)
            Next
    
        End Sub
    
        Private Sub timer1_Tick(sender As Object, e As EventArgs) Handles timer1.Tick
            Dim p, q As Particle
            Dim dx, dy, d As Double
    
            For i = 0 To Particles.Count - 1
                p = Particles(i)
    
                'check for collision using the distance between particles
                For j = 0 To Particles.Count - 1
                    If j <> i Then
                        q = Particles(j)
                        dx = p.Position.X - q.Position.X
                        dy = p.Position.Y - q.Position.Y
                        'distance between center points
                        d = Math.Sqrt((dx * dx) + (dy * dy))
                        'distance from particle perimeters
                        If d < p.Radius + q.Radius Then
                            'collision reverse directions
                            p.incrementx = -p.incrementx
                            p.incrementy = -p.incrementy
                            q.incrementx = -q.incrementx
                            q.incrementy = -q.incrementy
                        End If
                    End If
                Next
    
                p.Position.X += p.incrementx
                If p.Position.X < 0 Or p.Position.X > Me.ClientSize.Width - (p.Radius * 2) Then p.incrementx = -p.incrementx
    
                p.Position.Y += p.incrementy
                If p.Position.Y < 0 Or p.Position.Y > Me.ClientSize.Height - (p.Radius * 2) Then p.incrementy = -p.incrementy
    
                Particles(i) = p
    
            Next
    
            Me.Invalidate()
    
        End Sub
    
        Private Sub StartBth_Click(sender As Object, e As EventArgs) Handles StartBtn.Click
            timer1.Enabled = Not timer1.Enabled
    
            If timer1.Enabled Then
                StartBtn.Text = "Stop"
            Else
                StartBtn.Text = "Start"
            End If
        End Sub
    
        Private Sub AddBtn_Click(sender As Object, e As EventArgs) Handles AddBtn.Click
            AddParticle()
            Me.Invalidate()
        End Sub
    
        Private Sub AddParticle()
            Dim p As Particle = GetParticle()
            Particles.Add(p)
        End Sub
    
        Private Function GetParticle() As Particle
            With GetParticle
                .Position.X = 10
                .Position.Y = 50 + (10 * Particles.Count)
                .Radius = 10 + (5 * Particles.Count)
                .incrementx = 5 + Particles.Count * 2
                .incrementy = 5 + Particles.Count * 2
                Dim c As Integer
                c = Particles.Count * 40
                If c > 255 Then c = 255
                If c < 30 Then c = 30
                .color = Color.FromArgb(255, 255 - c, CInt(c / 2), c)
            End With
        End Function
    End Class

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2018
    Posts
    131

    Re: Experimenting With Game Ideas

    Thanks everyone, I did not know that GDI was a part of DirectX and OpenGL programming. Thanks for explaining that passel.

    tommytwotrain, Yes it was a VB6 question I came from vb6 a while ago so I was not sure as I am not up on things in vb .net just yet.

    Ok Thanks what I decided I want to do is a shooter game where objects fall from the top at different speeds and patterns.
    Different speeds seem like something I can manage for now but the patterns will have to wait.
    Also I will have an arkanoid like paddleball thing on the bottom to catch, shoot and bounce objects in the play field.

    So for now I would like to add an image on the bottom and then have 3 different images or animated gifs that can keep falling from the top.
    If I have different images of the same image I can animate it myself though also. For example if when the image was hit by an object it could show damage.
    Not sure exactly how to do this yet.

    ok so 3 falling images and lets just keep it simple and have it so that when the paddleball catcher thing touches or catches the images, the image will disappear and it will add points to the score label.
    So for each of the 3 images it will be different amounts of points awarded. 5, 10 and 20 Points
    oh also since I don't want the images falling all from the same position across the screen I will need to figure how to make them fall in different positions.

    This seems simple enough for me I think. Let me know what you think.

    Trying to find 3 images now, found 1 animated .gif but if you can help me figure out how I can get the one image falling smoothly and award points to the label I should be able to hopefully just add more since it is not really any different except the speed which would require a timer?

    I have a scrolling credits text example but it is not too smooth for some reason, it uses a label and a timer..

    I am going to want to try to do this with opengl or directx unless this is too difficult.. but I would like to find info on how to implement these. I know there are many places but where can I find reference info about how to use these api's? Should I even start with these apis's (opengl/directx)? or do you think it could be too difficult to get started with something like this?

    I will need some help figuring this out.

    Thanks
    Last edited by DreamWarrior77; Aug 10th, 2019 at 01:03 AM.

  8. #8
    Hyperactive Member
    Join Date
    Jun 2018
    Posts
    434

    Re: Experimenting With Game Ideas

    Yes that sounds reasonable. Like a space invaders or tetris game.

    "if I have different images of the same image I can animate it myself though also. For example if when the image was hit by an object it could show damage.
    Not sure exactly how to do this yet."

    Yeah. Thats why I mention gifs. You can play the gif using image animator. However you can just make a list of images in memory from the gif file (or just images does not have to come from a gif we can make our own gifs now) and we play the list on the screen as required etc.

    You can also draw vector graphics and animate them. That is what the example is. Drawing a circle is vector graphics. It is not a bitmap of a circle we recreated the circle from the vector geometry.

    "I am going to want to try to do this with opengl or directx "

    I see. Well you should do something simple first just using standard vb. You don't need direct x yet. First you need to learn the basics that vb.net will give you.

    You can use that basic shell example above. Change it to just drop a ball from the top of the form and move the ball to the bottom and then stop at the bottom.

    Why dont you do that? Just get the example above running. Then make a copy of the working shell and change the paths of the particles to just drop down from the top of the screen. You will only need one ball or particle or sprite or circle. You will have to make some kind of counter/AI in the timer tick event that will figure when to drop the ball etc. Similar to how the example checks for collisions and then makes a decision.

    You have to go one step at a time or you get overload and confusion and frustration. We want to have a working something that runs that we can add to and debug. Then programming is fun. We want to play with our baby as we design build it.

    So just change the example to drop circles from the top to the bottom. Dont worry about images or gifs or directx yet. Just a space invaders tetris type action.

    It will take some time just to learn and understand the example shell.

    You seem to have a good handle on it so far...

  9. #9
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,521

    Re: Experimenting With Game Ideas

    Quote Originally Posted by DreamWarrior77 View Post
    Thanks everyone, I did not know that GDI was a part of DirectX and OpenGL programming. Thanks for explaining that passel.
    ...
    I think you misunderstood.
    GDI stands for Graphics Device Interface and is the basis of the Windows GUI Graphics. It has been around since the beginning of Windows, in one form or another, i.e. a 16-bit interface version for the original Windows, and a 32-bit interface version for the later (Win95 on) versions of Windows.

    DirectX came along later, to give Windows programmers a more Direct way to access the graphics card (hence the name), to allow creating games that run in Windows that could compete with the DOS based games that had direct access to the hardware.
    OpenGL came from the Silicon Graphics universe. GL was the Graphics Library that provided access to the advanced graphics capabilities of the Silicon Graphics computers, which were the standard for advanced graphics and animation of their era, and most computer animated movies in the 80s used Silicon Graphics computers.

    GL was a comprehensive library that had both graphical libraries and hardware input routines. When the graphical capabilities of PCs with ever increasing capable graphic card advancements in the 90s became evident, SG decided to get into that market by releasing a library specification for the Graphics portion of the GL library, calling it OpenGL. OpenGL and DirectX were essentially in competition in some ways, and Microsoft's implementation of the OpenGL specification for Windows driver were rather weak compared to the DirectX libraries. So, the better OpenGL implementation for Windows had to come from third party sources.

    GDI+ is a newer Graphics Device Interface implementation. The main difference being that it is object oriented and implemented through a bunch of classes, rather than being a library of functions that you call. Since they were adding classes, and this is technically an extension, then new capabilities were added as well. But many of the objects are essentially new approaches to doing the same thing you could do with GDI, and do use GDI under the hood of the class.

    GDI is not part of DirectX or OpenGL programming.
    Also, if you want to use VB.Net as your language, then using DirectX or OpenGL would be a chore because neither library is supported by Microsoft for VB.Net or C#. They started to support DirectX with some class library around Visual Studio 2010, but didn't continue to support it. Using a WPF project rather than a Windows Form project, has some support built in to support some graphical capabilities of an older version of DirectX, but that has lagged.

    I believe, the only language that Microsoft promotes and maintains concurrency with DirectX is C++. So, if you want to be serious about DirectX, then you would want to be serious about using C++. But, with third party help, you can use some version of access to DirectX and OpenGl libraries from VB.Net and C#, but it isn't straight forward. I haven't had the patience to try and pursue using the advance libraries beyond an isolated simple experiment now and then over the years.

    I did put together an example of an approach to doing something like a space invaders game for a user on another forum years ago. That forum is no longer with us unfortunately. I had a basic design of an approach to the game, and implemented the same design three different ways for comparison. I used it as a test bed for other things, so don't know if I have a clean example around any longer.

    p.s. Windows also has an annoying habit of being inconsistent in how well different things work in the graphics and timing arena when coding winform based graphics. As soon as you think you have things figured out, and have a game or example of some portion of a game that works well on your machine, you can find that when you or others run it on another machine, it can function horribly slow or inconsistent.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2018
    Posts
    131

    Re: Experimenting With Game Ideas

    Thanks for clearing that up for me passel, awesome and thorough explanation of everything. Yeah I was reading about directx being unsupported but could not understand why since it is a Microsoft product. It kind of doesn't really add up if you know what I mean. I heard it last support version 9.. why have they stopped supported it though? If I am going to try to do it in c++ I hope I can figure out some basics. I am hardly decent with vb still so that could be a tough switch but I will have to try to see if maybe I can mess around with some c++ test projects in visual studio and see what I get get going.

    There is a lot I don't exactly understand, I love Visual Studio and have thought of trying c++ for a bit now but I am not sure I have all the details I need. I was looking into cross platform programming because I like a little Linux every once and a while, but I love that it's free and anyone can alter and program stuff for it as well. So I was looking into it and as we know Visual Studio is only for windows, I know they now have Visual Studio Code but I don't think they have all the tools, like for example the drag n drop tools in win forms.. correct me if I am wrong but it does not have that I don't think. So I was confused about that and how that works on Visual Studio Code.. I always use all that stuff, textboxes, listboxes, labels, command buttons, combo boxes.. etc.. How can you do that in VS Code? I really wanted to try to do some coding on Linux but without knowing this answer I was shut down from attempting to give it a try.

    If I used VS Code or VS Studio I would try to go with opengl maybe in c++ that is really what I should be doing anyway if I am serious about graphics programming.
    For now though I can try to experiment with it and see if I can learn some basics. If you know how to use those drag n drop tools for forms in VS Code please let me know, I really wanted to try VS Code since it's cross platform. I tried researching others like eclipse and a few others I forget but they all seemed hard to use for me personally. People have said python is so easy to learn but I tried to install it and it just seemed like something that was not for me either. My type of stuff is ready made forms that you can drop controls onto and then go from there rather than actually program the form and controls. RAD Tools are my thing, is there anything that comes close to Visual Studio that is cross platform? Thanks..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width