Are you the publisher? Claim or contact us about this channel


Embed this content in your HTML

Search

Report adult content:

click to rate:

Account: (login)

More Channels


Channel Catalog


Channel Description:

Post your questions about every aspect of developing games and graphics applications. Topics include using DirectX and the GDI32 API, XNA,etc. (non-VB questions allowed)

older | 1 | .... | 10 | 11 | (Page 12)

    0 0

    how convert vbcolor or commondialog color to GDIPLUS color?

    0 0

    see how i create a Memory DC: Code: --------- Public Sub NewImage(width As Long, height As Long, Optional backcolor As Long = White) If (ImageBitmap) Then SelectObject ImageHDC, OldImageBitmap DeleteObject ImageBitmap DeleteDC ImageHDC End If If (ImageGraphics) Then GdipDeleteGraphics ImageGraphics ImageHDC = CreateCompatibleDC(GetDC(0)) If (ImageHDC = 0) Then Debug.Print "error" ImageBitmap = CreateCompatibleBitmap(GetDC(0), width, height) If (ImageBitmap = 0) Then Debug.Print "error on ImageBitmap" OldImageBitmap = SelectObject(ImageHDC, ImageBitmap) Dim hBrush As Long hBrush = CreateSolidBrush(backcolor) If (hBrush = 0) Then Debug.Print "error on brush" Dim rect As rect rect.Left = 0 rect.Top = 0 rect.Bottom = height rect.Right = width If (FillRect(ImageHDC, rect, hBrush) = 0) Then Debug.Print "error on FillRect" ImageBackColor = backcolor lngwidth = width lngheight = height DeleteObject hBrush End Sub --------- now see how i read the file and draw the cursor to it: Code: --------- Public Sub FromFile(FileName As String) If (hBitmap) Then GdipDisposeImage (hBitmap) If (CurAni) Then DeleteObject (CurAni) imgType = GetImageType(FileName) If (imgType = ANI Or imgType = CUR) Then Debug.Print "cursor" 'yes it's printed CurAni = LoadImage(App.hInstance, FileName, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE) NewImage 100, 100 'If (DrawIconEx(GetWindowDC(GetForegroundWindow()), 0, 0, CurAni, 0, 0, 0, 1, DI_NORMAL Or DI_IMAGE) = 0) Then Debug.Print "error on draw cursor: " & GetLastError If (DrawIconEx(ImageHDC, 0, 0, CurAni, 0, 0, 0, 1, DI_NORMAL Or DI_IMAGE) = 0) Then Debug.Print "error on draw cursor: " & GetLastError Else Call GdipLoadImageFromFile(StrPtr(FileName), hBitmap) NewImage width, height GdipCreateFromHDC ImageHDC, hGraphics GdipDrawImage hGraphics, hBitmap, 0, 0 GdipDeleteGraphics hGraphics End If End Sub --------- heres how i draw on form: Code: --------- Public Sub Draw(DestinationHDC As Long, Optional Transparent As Boolean = True) RaiseEvent BeforeDrawImage(intSelectedFrame) If (ImageHDC = 0) Then Debug.Print "no hDC" If (Transparent = True) Then Dim BF As Long Const USE_BITMAP_ALPHA = &H1000000 'AC_SRC_ALPHA scaled up to the 4th byte of a long BF = 128 * &H10000 'semi transparent ignoring bitmaps alpha channel BF = 255 * &H10000 Or USE_BITMAP_ALPHA 'fully opaque using bitmaps alpha channel Dim btMap As BITMAP If (GetObject(ImageBitmap, Len(btMap), btMap) = 0) Then Debug.Print "error" Dim s As BITMAPINFO Dim BytesPerScanLine As Long s.bmiHeader.biSize = 40 s.bmiHeader.biPlanes = 1 s.bmiHeader.biBitCount = 24 s.bmiHeader.biHeight = height s.bmiHeader.biWidth = width s.bmiHeader.biPlanes = btMap.bmPlanes s.bmiHeader.biCompression = 0 BytesPerScanLine = ((s.bmiHeader.biWidth * 3) + 3) And &HFFFFFFFC s.bmiHeader.biSizeImage = BytesPerScanLine * s.bmiHeader.biHeight Dim ImageData() As Byte ReDim ImageData(3, s.bmiHeader.biWidth, s.bmiHeader.biHeight) GetDIBits ImageHDC, ImageBitmap, 0, s.bmiHeader.biHeight, ImageData(0, 0, 0), s, 0 If (ImageData(0, 0, 0) = 0) Then 'testing if have a alpha value AlphaBlend DestinationHDC, 0, 0, width, height, ImageHDC, 0, 0, width, height, BF Else TransparentBlt DestinationHDC, 0, 0, width, height, ImageHDC, 0, 0, width, height, GetPixel(ImageHDC, 0, 0) End If Else BitBlt DestinationHDC, 0, 0, width, height, ImageHDC, 0, 0, vbSrcCopy End If 'DrawIconEx DestinationHDC, 0, 0, CurAni, 0, 0, 0, 1, DI_NORMAL Or DI_IMAGE 'works End Sub --------- the DrawIconEx() don't give me any error. so why the cursor isn't drawed on Memory DC? (on form is drawed, i had tested)

    0 0
  • 12/21/16--07:03: How to create Animated GIFs
  • Hey everyone, I just wanted to say that VBforums is awesome! Out of every online community I have been in, this one has been the most supportive. Thanks! Anyway, I have been trying for a couple of days now at work to compile a series of images into an animated GIF using the GDI+ library. I don't have access to any other image processing libraries so if at all possible I'd like to stick to using that one. I am putting together a program to automate some on screen actions in a 3D program and take screen shots at the same time. Those screen shots are saved to the Hard drive and are named chronologically. So far this functionality has been developed and is working well. At this point though I am not sure what to do. I have seen some online examples in C# using the GDI+ library but I don't understand it. I have been studying and testing portions of code from the following link: http://www.dreamincode.net/forums/topic/256154-gif-animation-editing-and-processing-program/ Specifically the Assemble() subroutine where according to the author is where the animated GIF is made (Below it can be viewed). There is miscellaneous code in there pertaining to Form controls, but besides those, it seems like the images are being looped through one at a time and being opened with BinaryWriter, and eventually saved to a MemoryStream in the format of a GIF. At the end of the subroutine it looks like the compiled GIF is displayed in a PictureBox form control. At least this is what I gathered so far. I don't quite understand how the image is being assembled though. I have never used MemoryStream or BinaryWriter before and it looks the image is saved to MemoryStream before it's finally displayed. Also, what are the Bytes data type for and what does that accomplish? Can somebody help me make sense of what is going on this code. Is this going to help me create and save an animated GIF with my screenshots or should I resort to using something else? Thank you for your time. Code: --------- Public Sub Assemble(ByVal But As Integer) Me.Cursor = Cursors.WaitCursor 'Variable declaration Dim memoryStream As MemoryStream Dim binaryWriter As BinaryWriter Dim image As Image Dim buf1 As [Byte]() Dim buf2 As [Byte]() Dim buf3 As [Byte]() memoryStream = New MemoryStream() buf2 = New [Byte](18) {} buf3 = New [Byte](7) {} buf2(0) = 33 'extension introducer buf2(1) = 255 'application extension buf2(2) = 11 'size of block buf2(3) = 78 'N buf2(4) = 69 'E buf2(5) = 84 'T buf2(6) = 83 'S buf2(7) = 67 'C buf2(8) = 65 'A buf2(9) = 80 'P buf2(10) = 69 'E buf2(11) = 50 '2 buf2(12) = 46 '. buf2(13) = 48 '0 buf2(14) = 3 'Size of block buf2(15) = 1 ' buf2(16) = 0 ' buf2(17) = 0 ' buf2(18) = 0 'Block terminator buf3(0) = 33 'Extension introducer buf3(1) = 249 'Graphic control extension buf3(2) = 4 'Size of block buf3(3) = 9 'Flags: reserved, disposal method, user input, transparent color buf3(4) = 10 ' 88 If ckSlide.Checked = True Then 'Delay time low byte buf3(5) = 1 'Delay time high byte buf3(6) = 0 Else 'Delay time low byte buf3(5) = 0 '1 'Delay time high byte buf3(6) = 255 End If 'Transparent color index buf3(7) = 0 'Block terminator NewName = GetNewName1() lbOutput.Text = NewName binaryWriter = New BinaryWriter(File.Open(NewName, FileMode.Create)) For picCount As Integer = 0 To ImageArray.Count - 1 'stringCollection.Count - 1 Select Case But Case 1 'Animate image = Bitmap.FromFile(ImageArray(picCount)) If ckDark.Checked = True Then image = Dark(image) If rbSepiaTone.Checked = True Then image = Sepia(image) If rbGrayScale.Checked = True Then image = Grayscale(image) If ckGhost.Checked = True Then Ghost(image) If ckFlip.Checked = True Then image.RotateFlip(RotateFlipType.RotateNoneFlipX) Case 2 If MemPic IsNot Nothing Then image = MemPic(picCount) If ckDark.Checked = True Then image = Dark(image) If rbSepiaTone.Checked = True Then image = Sepia(image) If rbGrayScale.Checked = True Then image = Grayscale(image) If ckGhost.Checked = True Then Ghost(image) If ckFlip.Checked = True Then image.RotateFlip(RotateFlipType.RotateNoneFlipX) Else MessageBox.Show("Please Select Something") End If End Select image.Save(memoryStream, ImageFormat.Gif) buf1 = memoryStream.ToArray() If picCount = 0 Then 'only write these the first time.... binaryWriter.Write(buf1, 0, 781) 'Header & global color table 'Application extension binaryWriter.Write(buf2, 0, 19) End If binaryWriter.Write(buf3, 0, 8) 'Graphic extension binaryWriter.Write(buf1, 781, buf1.Length - 782) 'Image data ' If picCount = stringCollection.Count - 1 Then If picCount = ImageArray.Count - 1 Then 'only write this one the last time.... 'Image terminator binaryWriter.Write(";") End If memoryStream.SetLength(0) Progress.Value = 100 * picCount / ImageArray.Count Next binaryWriter.Close() pbSelect.Invalidate() memoryStream.Close() Me.Cursor = Cursors.Default pbSelect.Image = image.FromFile(ImageArray(N)) pbSelect.Refresh() Progress.Value = 0 End Sub ---------

    0 0

    hi. I want make a project to can read PSD File and show layers in transparentform in vb6.any way ? for example i have 2 layer in PSD File and their name are Button and Button_Over,so i want read two layers and show in transparent form and when i move my mouse on button layer,show Button_over layer on it. I found samples to can read psd file and show layers on form but cant show on transparent form?

    0 0

    There are three games in three separate workbooks: 1. Tetris 2. Find Matches 3. Rocket https://www.youtube.com/watch?v=SpbwXQCcIu8

    0 0
  • 03/21/17--23:41: Where's all the threads
  • I only see 3 threads not counting this one EDIT Never mind. I see what the reason was

    0 0

    This is what I have so far. If you click anywhere, the spaceship will rotate 90 degrees. What I am trying to do is a little confusing. I want the player to be able to click anywhere around the spaceship. If the player clicks above and to the right, then I want the spaceship to face up or right. If it faces up or right, then the facing direction depends on what was further in the click (x or y). If the player clicked further right then up, then the ship will face right, if the player clicked further up then right, then the ship should face up. How can I do this? Spaceship image Attachment 146551 (http://www.vbforums.com/attachment.php?attachmentid=146551) Code: --------- Public Class Form1 Dim bm As New Bitmap("spaceship.gif") Dim spaceshipx As Integer = 250 Dim spaceshipy As Integer = 250 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Private Sub PictureBox1_Paint(sender As Object, e As PaintEventArgs) Handles PictureBox1.Paint e.Graphics.DrawImage(bm, spaceshipx - 16, spaceshipy - 16) End Sub Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown bm.RotateFlip(RotateFlipType.Rotate90FlipNone) PictureBox1.Invalidate() End Sub End Class ---------

    0 0

    Edit, Nm, I have this fixed. I dropped the sprites and simply drawing everything using vertexBuffers. Hey all, I have an app that currently uses GDI to drawing pdf page renderings (images) and it provides markup tools so the user can modify the pdf docs. This has been working great until I was handed a 5000px X 3000px image with 40-50 markups. This kind of made GDI snort cough and gag. I've start moving that portion of the app to DirectX (because I have some (a little) experience with it). To draw the original image I have created a quad on the XY plane (z=0) and use the image to create a texture. When I draw the quad, I set the texture and draw the image. This works great. I have also implement pan and zoom which basically moves the camera around. To pan, I move the camera in a plane parallel to the XY plane. To zoom I simply change the camera's Z coordinate. This all works fine. To place the markups in the drawing, I have created a sprite wrapper that contains the location and texture for the markup (the texture is created from an image made using GDI). When it comes time to draw the markups, I use a single sprite, call the its Draw method and pass the texture, and location. This too works but it's drawing the sprites in screen coordinates, not in world coordinates, so I believe they need to be transformed, but I don't know how. Can some explain to me how I need to transform my sprites so they go where I need them to be? Here is vb.net code I'm using to draw the sprite. It gets called from the game loop. I am using vb.net, but I can translate from just about any other language (c++ no so good, but I'll give it a go if need be). Private Sub DrawSprite(ByVal _wrapper As spriteWrapper) Static mSprite As New Sprite(device) mSprite.Begin(SpriteFlags.None) Dim center As Vector3 = New Vector3(0.0F, 0.0F, 0.0F) 'the upper left corner of the sprite is 0,0 Dim position As Vector3 = New Vector3(_wrapper.Location.X, _wrapper.Location.Y, 0) mSprite.Draw(_wrapper.texture, Rectangle.Empty, center, position, Color.White) mSprite.End() End Sub Thanks for looking! kevin

    0 0

    Hello, to start off i am a student in a Visual basic programming class, so im pretty new to VB and coding in general. For an assignment we have to recreate a game or create a new game, and i decided to do a simple version of an old favorite of mine, Advance Wars. It is similar to fire emblem or many other turn based strategy games in mechanics. So far i have created a picturebox array and set the background image of the pictureboxes to be the grass background that i made, and i couldnt figure out how to put the buildings and environment images on top of the grass background, so i set up specific for loops setting the tiles i wanted to the image i wanted, which works decently well, but im not sure how i can put soldiers and other units onto the battlefield and allow them movement without changing the tiles that are in the background like the grass or buildings. I tried setting the array as a 3d array and putting the soldiers on the highest z coordinate, but it didnt appear to do anything. I looked up this post: http://www.vbforums.com/showthread.php?646540-two-layers-of-graphics and tried to implement XNA into my project, but im not really sure how XNA works or how i should change what i currently have to work with XNA. I'm sorry if i don't explain everything very well, im not really sure what i should say because i havent really done this before. Is there an easier way to code what im trying to do, or is learning XNA and using it the easiest way to do this? This is what i have as far as the code is concerned: Code: --------- Imports Microsoft.Xna.Framework Imports Microsoft.Xna.Framework.Graphics Imports Microsoft.Xna.Framework.Input Public Class Game1 Inherits System.Windows.Forms.Form Dim Grid(,,) As Cell Private Sub Game1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Me.Show() Me.Focus() Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Me.WindowState = FormWindowState.Maximized 'Setting Up Array ReDim Grid(15, 9, 2) For x = 0 To 15 For y = 0 To 9 For z = 1 To 1 'MessageBox.Show(x & " " & y) Grid(x, y, z) = New Cell AddHandler Grid(x, y, z).Click, AddressOf TileSelect_click Grid(x, y, z).Height = 90 Grid(x, y, z).Width = 90 Grid(x, y, z).Top = y * 90 Grid(x, y, z).Left = x * 90 Me.Controls.Add(Grid(x, y, z)) Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch 'Grid(x, y, z).BackColor = Color.LawnGreen Grid(x, y, z).BackgroundImage = My.Resources.Grass_Texture_v2 'Grid(x, y, z).City = True Next Next Next 'Blue Buildings For x = 1 To 1 For y = 1 To 1 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Blue_Capital_Grass Grid(x, y, z).Blue = True Grid(x, y, z).Capital = True Next Next Next For x = 0 To 1 For y = 0 To 0 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Blue_City_Grass Grid(x, y, z).Blue = True Grid(x, y, z).City = True Next Next Next For x = 0 To 0 For y = 2 To 2 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Blue_City_Grass Grid(x, y, z).Blue = True Grid(x, y, z).City = True Next Next Next For x = 2 To 2 For y = 1 To 2 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Blue_Factory_Grass Grid(x, y, z).Blue = True Grid(x, y, z).Factory = True Next Next Next 'Red Buildings For x = 14 To 14 For y = 8 To 8 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Red_Capital_Grass Grid(x, y, z).Red = True Grid(x, y, z).Capital = True Next Next Next For x = 14 To 15 For y = 9 To 9 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Red_City_Grass Grid(x, y, z).Red = True Grid(x, y, z).City = True Next Next Next For x = 15 To 15 For y = 7 To 7 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Red_City_Grass Grid(x, y, z).Red = True Grid(x, y, z).City = True Next Next Next For x = 13 To 13 For y = 7 To 8 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Red_Factory_Grass Grid(x, y, z).Red = True Grid(x, y, z).Factory = True Next Next Next 'Neutral Buildings For x = 7 To 7 For y = 4 To 4 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Open_Factory_Grass Grid(x, y, z).Neutral = True Grid(x, y, z).Factory = True Next Next Next For x = 6 To 6 For y = 3 To 3 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Open_City_Grass Grid(x, y, z).Neutral = True Grid(x, y, z).City = True Next Next Next For x = 8 To 8 For y = 5 To 5 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Open_City_Grass Grid(x, y, z).Neutral = True Grid(x, y, z).City = True Next Next Next 'Environment For x = 5 To 9 For y = 2 To 2 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Mountain_Texture_Grass Grid(x, y, z).Mountain = True Next Next Next For x = 5 To 9 For y = 6 To 6 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Mountain_Texture_Grass Grid(x, y, z).Mountain = True Next Next Next For x = 9 To 9 For y = 3 To 5 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Trees_Texture_Grass Grid(x, y, z).Trees = True Next Next Next For x = 5 To 5 For y = 3 To 5 For z = 1 To 1 Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).BackgroundImage = My.Resources.Trees_Texture_Grass Grid(x, y, z).Trees = True Next Next Next Private Sub TileSelect_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim MyTile As Cell = sender If MyTile.Factory = True Then ReDim Grid(15, 9, 0) For x = 3 To 3 For y = 1 To 1 For z = 0 To 0 Grid(x, y, z) = New Cell Grid(x, y, z).BackgroundImageLayout = ImageLayout.Stretch Grid(x, y, z).Image = My.Resources.Blue_Soldier Grid(x, y, z).Soldier = True MessageBox.Show("Soldier Created") Next Next Next End If If MyTile.Capital = True Then MessageBox.Show("This is a Capital") End If End Sub End Class --------- I have the Cell Class which just inherits PictureBox and then declares Booleans for what the tiles are, like .Red or .Soldier Again im sorry im so new, i know some of VB, and therefore some understanding of C#, but i know nothing about XNA or how it works. How i want the game to function in the end is a turn based strategy game where each player get an amount of funds per turn, which is based on the number of buildings they own, which they can spend at factories to purchase units varying in cost and power (total of 4 units: Infantry, Recon, Artillery, Tank). The main goal is to take over the enemy player's Capital building. Buildings can be taken over by infantry. The battle system works on a system where each unit starts at 10 health and deals damage based on the weapon they have and the armor/lack of armor of their opponent. Thanks for any help.

    0 0

    it's easy using\draw the X and Y points. but i don't understand how i can draw the Z. can anyone explain to me how can i draw the point Z? (i never used the Z and i didn't learned from school)

    0 0

    how we can draw dots across a line? see the image: Attachment 148093 (http://www.vbforums.com/attachment.php?attachmentid=148093) like you see the red dots(are ellipses) aren't above the line, unless i resize the form. heres the code: Code: --------- Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load SetStyle(ControlStyles.ResizeRedraw, True) End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim s As Graphics = e.Graphics s.SmoothingMode = Drawing2D.SmoothingMode.HighQuality s.DrawLine(Pens.Black, New Point(0, 0), New Point(Me.ClientSize.Width, Me.ClientSize.Height)) s.DrawLine(Pens.Black, New Point(CInt(Me.ClientSize.Width / 2), 0), New Point(CInt(Me.ClientSize.Width / 2), Me.ClientSize.Height)) s.DrawLine(Pens.Black, New Point(0, CInt(Me.ClientSize.Height / 2)), New Point(Me.ClientSize.Width, CInt(Me.ClientSize.Height / 2))) Dim x As Integer = 0 For y As Integer = 0 To Me.ClientSize.Height Step 10 'For x As Integer = 0 To Me.ClientSize.Width Step 10 s.FillEllipse(Brushes.Red, New Rectangle(CInt(x - (10 / 2) + 1), CInt(y - (10 / 2) + 1), 9, 9)) x += 22 'Next Next End Sub --------- how can i correct the calculation?

    0 0

    using Matrix.RoateAt(), we can rotate the image like the clock. but we can rotate on horizontal and vertical way?

    0 0

    how we can draw dots across a line? see the image: Attachment 148093 (http://www.vbforums.com/attachment.php?attachmentid=148093) like you see the red dots(are ellipses) aren't above the line, unless i resize the form. heres the code: Code: --------- Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load SetStyle(ControlStyles.ResizeRedraw, True) End Sub Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim s As Graphics = e.Graphics s.SmoothingMode = Drawing2D.SmoothingMode.HighQuality s.DrawLine(Pens.Black, New Point(0, 0), New Point(Me.ClientSize.Width, Me.ClientSize.Height)) s.DrawLine(Pens.Black, New Point(CInt(Me.ClientSize.Width / 2), 0), New Point(CInt(Me.ClientSize.Width / 2), Me.ClientSize.Height)) s.DrawLine(Pens.Black, New Point(0, CInt(Me.ClientSize.Height / 2)), New Point(Me.ClientSize.Width, CInt(Me.ClientSize.Height / 2))) Dim x As Integer = 0 For y As Integer = 0 To Me.ClientSize.Height Step 10 'For x As Integer = 0 To Me.ClientSize.Width Step 10 s.FillEllipse(Brushes.Red, New Rectangle(CInt(x - (10 / 2) + 1), CInt(y - (10 / 2) + 1), 9, 9)) x += 22 'Next Next End Sub --------- how can i correct the calculation?

    0 0
  • 06/19/17--15:47: Fishing Program
  • I'm just a fan of fishing and would like to create a game. I already have a plan of it. Which is the next step?

    0 0

    Anyway if you aren't familiar with Masters of Orion 1, it uses a 2D map of space with stars spread randomly around. Although it shows stars in all practical terms the stars are actually planets that may or may not be habitable. The game map can be several sizes (24 to 100+ stars). When performing your turn you see only a portion of the entire game map (basically zoomed in so you can see details) then when the game is processing your commands and figuring out what the Computer players are doing it displays the entire map with ship movement etc being displayed. You can also get the zoomed out view during your turn by hitting the "Map" button. Clicking on stars/ships displays its details in a sidebar. Everything on the map is clickable and when you do click on a star, ship, monster, whatever, it switches back to the zoomed in view with the clicked item centered and highlighted (or close enough to centered if the object was on the edges of the map). Navigating around the map is done by simply clicking near the edges and the view slides in that direction. Ships in the game travel in a straight line between stars and distances are calculated as the crow flies, not by any kind of grid cell counts though there is obviously some form of grid use when it comes to star placements. So I'm looking for suggestions on how to achieve this kind of 2D graphics functionality (not necessarily code, just point to examples/write ups/whatever you think would be useful). I'm flying blind as I've never even attempted something in the 2D map realm, its all a mystery at the moment. As an example, how to place stars and ships and make them selectable?. Should I have some sort in internal grid (math only) for placements? Something like a grid where the click position is divided by the number of cells which gives an index to look up data (either X/Y or a single dimension calculated by an X index and adding Y * XMax (e.g. one row has 200 positions, clicking in the area of the first row gives X + 0, second row gives X + 200, third X + 400, you get the idea). Or am I barking up the wrong tree entirely? Next is the map graphic - sticking a picture in a scrolling picture box is probably not going to cut it (though it might, this is just my assumption). I found an old bit of source for a similar game and it used Gorgon library (which I believe is the same idea as XNA/Monoplay). I get the feeling I should probably look into some form of library for 2D games. Anyone have a favorite? I'll stop babbling now. Looking forward to any suggestions people may have!

    0 0

    If you guys haven't heard Microsoft has started its Mixed Reality journey with Hololens and the open-source library HoloToolKit. Unfortunately, Unity doesn't support VB as a scripting language although there may be some hope as they transition to .NET Standard in the future. In the meantime, I've decided to port the HoloToolKit to VB. But there is a lot of code that needs to be ported to class libraries that can only target .NET Framework 3.5. Do you have thoughts on whether of not this is worth the investment? After all, Microsoft is adding new code to the repository all the time, but it is all in C#. All Unity tutorials are in C# as well. It would be extremely difficult to keep up with it if I don't have some outside help. This was the only Visual Basic forum I could find, so I could use all the helping hands I could get. I don't want to mix C# scripts with VB dlls either. Any thoughts on how to proceed? The original HoloToolKit (written in C#): https://github.com/microsoft/HoloToolkit-Unity Here's my fork of the HoloToolKit (re-written in VB class libraries): https://github.com/dvdalimi/HoloToolkit-Unity-VB/wiki

older | 1 | .... | 10 | 11 | (Page 12)