Jump to content
Xtreme .Net Talk

Loffen

Avatar/Signature
  • Posts

    51
  • Joined

  • Last visited

Everything posted by Loffen

  1. Didnt understand that 100% ether? Ill post my GameEngine Class... The code i am talking about is almost at the bottom.. [color=Blue]Imports[/color] Microsoft.DirectX [color=Blue]Imports[/color] Microsoft.DirectX.Direct3D [color=Blue]Imports[/color] Microsoft.DirectX.Direct3D.D3DX [color=Blue]Imports[/color] System.Math [color=Blue]Public Class[/color] GameEngine [color=Blue]Inherits[/color] GraphicsEngine [color=Blue]Public[/color] Graphics [color=Blue]As[/color] GraphicsEngine [color=Blue]Public Function[/color] Init([color=Blue]ByVal[/color] Target [color=Blue]As[/color] System.Windows.Forms.Form) Graphics = [color=Blue]New[/color] GraphicsEngine Graphics.BackBufferWidth = 800 Graphics.BackBufferHeight = 600 Graphics.BackBufferFormat = Format.A8R8G8B8 Graphics.BackBufferCount = 1 Graphics.SwapEffect = SwapEffect.Copy Graphics.PresentInterval = PresentInterval.One Graphics.CreateFlags = CreateFlags.HardwareVertexProcessing [color=Blue]Or[/color] CreateFlags.MultiThreaded Graphics.DeviceType = DeviceType.Hardware Graphics.GraphicsTarget = Target Graphics.GraphicsInitDevice() [color=Green]'This is the map object[/color] Graphics.Map = [color=Blue]New[/color] GraphicsMap Graphics.Map.LoadMap(Graphics.Device, "testmap") Graphics.Player = [color=Blue]New[/color] GraphicsSprite(Graphics.Device, Application.StartupPath & "\objects\human1\human1.bmp", New Point(0, 0), 16, 16, &HFF00FF00) [color=Green]'//-------------------------------------------------- '// Different font types '//--------------------------------------------------[/color] Graphics.MessageText = [color=Blue]New[/color] GraphicsText(Graphics.Device, "Verdana", 8, FontStyle.Bold) Graphics.MissionText = [color=Blue]New[/color] GraphicsText(Graphics.Device, "Verdana", 18) Graphics.HUDText = [color=Blue]New[/color] GraphicsText(Graphics.Device, "Verdana", 22, FontStyle.Bold) [color=Blue]While[/color] Graphics.GraphicsRunning = [color=Blue]True[/color] [color=Green]'This is the function wich again calls the Overridable Render() function..[/color] [color=Red][b] !! HERE !![/b][/color] Graphics.GraphicsRenderLoop() Application.DoEvents() [color=Blue]End While[/color] Graphics.Player.Destroy() Graphics.Map.DestroyMap() [color=Blue] End End Function [color=Red][b]!! AND HERE !![/b][/color] Public Overrides Function[/color] Render() [color=Green]'The message box wont pop up...[/color] MessageBox.Show("Inside the correct render function!!") [color=Blue]End[/color] [color=Blue]End Function End Class[/color]
  2. Neee.... not 100% sure what you mean?? I want to run the code inside: Public Overrides Function Render(). The overwritten function is only there so my Graphics Class knows what function to call uring rendering. And as the object rendered are different from game to game. Later i probably will put the whole Graphics class into a dll, thets why i need the function so the 'caller' can render whatever the 'caller' wants Public Overridable Function Render() 'Should be overwritten. Nothing inside here sould be executed, only inside the other Render() End Function Public Overrides Function Render() Messagebox.show("In overrides Render()") 'Here the code sould be executed... End Function !! It wont let me place MyBase.Render() inside Public Overridable Function Render()
  3. It just wont run the code inside Public Overrides Function Render()
  4. Err... Yeah i did mean that... *Fixed* Actually this is a part of my game made with DirectX, Where SubFunction is the Render() function... Posting the class again whith changes... Hope it get clearer then... [color=Blue]Class[/color] GameEngine [color=Blue]Inherits[/color] GraphicsEngine [color=Blue]Private[/color] Graphics [color=Blue]as[/color] GraphicsEngine [color=Green]'This is called from form1..[/color] [color=Blue]Public Function[/color] Init() Graphics = [color=Blue]new[/color] GraphicsEngine Messagebox.show("Init Success") Graphics.RenderLoop() [color=Blue]End Function[/color] [color=Blue]Public Overrides Function[/color] Render() Messagebox.show("In overrides Render()") [color=Blue]End Function End Class[/color] [color=Blue]Class[/color] GraphicsEngine [color=Blue]Public Function[/color] RenderLoop() Device.Clear() DeviceBeginScene() Render() Device.EndScene() Device.Present() [color=Blue]End Function[/color] [color=Blue]Public Overridable Function[/color] Render() [color=Green]'Should be overwritten[/color] [color=Blue]End Function End Class[/color]
  5. I have two classes, like these: Class MainClass Inherits SubClass Private NewClass as SubClass Public Function Test() NewClass = new SubClass Messagebox.show("TestBox :p") NewClass.DoSomething() End Function Public Overrides SubFunction() Messagebox.show("Yup it works!!") End Function End Class Class SubClass Public Function DoSomething() 'Do something SubFunction 'Do something End Function Public Overridable Function SubFunction() 'Should be overwritten End Function End Class But only the first messagebox appears... What am i doing wrong? I get no errors or anything..
  6. Ahhhh!!! Got IT!!!! I was using: pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, [color=Red][b]3[/b][/color]) and NOT: pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, [color=Red][b]2[/b][/color]) Rolling around on floor trying to struggle myself with some wires... Thank to all of you who helped me so far... ;) --Loffen
  7. Did it like this (the same as you in Tutorial #2): Device.Transform.View = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, PP.BackBufferHeight, 0, 0, 10) But guess what, Still no result... This makes me very maad...........
  8. Tried both now... :( Should i post my whole project??
  9. Poff... Feel suddenly small :p. The only thing i set looking like this is: Device.Transform.Projection = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, 0, PP.BackBufferHeight, 0.0F, 0.0F) Device.Transform.Projection = Projection Matrix?? EDIT: I noticed that the order of OrthoOffCenterLH was not left, right, top, bottom but left, right, bottom, top. So therefore i changed my code to this: Device.Transform.Projection = Matrix.OrthoOffCenterLH(0, PP.BackBufferWidth, PP.BackBufferHeight, 0, 0.0F, 0.0F) Still no result though :p BTW: http://www.freewebs.com/ is free. No AD's (last time i was there) the only thing is a little copyright line...
  10. yup, 2003 :p BTW: I wrote(ehrr.. modified a not working class) a working text class: Imports Microsoft.DirectX Imports Microsoft.DirectX.Direct3D Imports Microsoft.DirectX.Direct3D.D3DX Imports System.Math Public Class clsLoffText Private pDevice As Device Dim TheFont As Font = Nothing Dim rect As New Rectangle(0, 0, 0, 0) Dim s As Direct3D.Sprite Public Sub New(ByVal pDevice As Device, Optional ByVal FontName As String = "Courier", Optional ByVal Size As Integer = 10) TheFont = New Font(pDevice, New System.Drawing.Font(FontName, Size)) s = New Sprite(pDevice) End Sub Public Sub Drawtext(ByVal text As String, ByVal cColor As System.Drawing.Color, ByVal rect As System.Drawing.Rectangle) s.Begin() TheFont.DrawText(text, rect, 0, cColor) s.End() End Sub End Class
  11. Yup i do render it: Graphics.Sprite = New GraphicsSprite(Graphics.Device, "grass.bmp", New Point(0, 0), 32, 32) Then in Render(): Graphics.Sprite.Render()
  12. I SHOULD have 2003, but i cant find a version number..
  13. Oh my! You site is uber bannered :p About coll. det. I was thinking smooth movement (one pixel each time, not one tile...) is this way harder?? I read an article somewhere, something about a special way of coll. det., very easy, accurate and you can move pixel by pixel... (where i dreaming or could this be true?) Got your example... :D. But my sprite class suddenly stopped showing the sprites. What am i doing wrong do you think :confused: ? Here it is: Imports Microsoft.DirectX Imports Microsoft.DirectX.Direct3D Imports Microsoft.DirectX.Direct3D.D3DX Imports System.Math Public Class FearGraphicsSprite Private pDevice As Device Private SpriteImage As Texture Private SpriteBuffer As VertexBuffer Public Sub New(ByVal lDevice As Device, ByVal ImageName As String, ByVal TopLeft As Point, ByVal Width As Integer, ByVal Height As Integer) pDevice = lDevice Load(ImageName, TopLeft, Width, Height) End Sub Public Sub Load(ByVal ImageName As String, ByVal topleft As Point, ByVal width As Integer, ByVal height As Integer) Dim Vertices() As CustomVertex.PositionTextured Try SpriteImage = TextureLoader.FromFile(pDevice, ImageName) Catch MessageBox.Show("Could not load image: " & ImageName, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End End Try SpriteBuffer = New VertexBuffer(GetType(CustomVertex.PositionTextured), 4, pDevice, Usage.WriteOnly, CustomVertex.PositionTextured.Format, Pool.Default) Vertices = SpriteBuffer.Lock(0, LockFlags.None) Vertices(0) = New CustomVertex.PositionTextured(topleft.X, topleft.Y, 1, 0, 0) Vertices(1) = New CustomVertex.PositionTextured(topleft.X + width, topleft.Y, 1, 1, 0) Vertices(2) = New CustomVertex.PositionTextured(topleft.X, topleft.Y + height, 1, 0, 1) Vertices(3) = New CustomVertex.PositionTextured(topleft.X + width, topleft.Y + height, 1, 1, 1) SpriteBuffer.Unlock() End Sub Public Sub Render() pDevice.VertexFormat = CustomVertex.PositionTextured.Format pDevice.SetStreamSource(0, SpriteBuffer, 0) pDevice.SetTexture(0, SpriteImage) pDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 3) End Sub End Class Yes we did think a little of the same. Saw your class somewhere on these forums... EDIT: I tried your class too... still nothing
  14. What is a title? :p Ok, I fixed a sprite class. I am reading the file line after line, then i split each line into a multidimensional array. Like this: MapTiles(row, tile) = TileNum This gives me an array something like this: MapTiles(1,1) = 0 MapTiles(1,2) = 0 MapTiles(2,1) = 1 MapTiles(2,2) = 0 MapTiles(3,1) = 1 MapTiles(3,2) = 1 How do you create a map from this from this?? Is this an efficent way?? BTW: I will try to move the camera and the player, after some planning i figured it will be easier to make a multiplayer thing if i can send player coords to the server... BTW2: Do you know somewhere with nice 2D Collision detection docs?? EDIT: BTW3: Does someone know why dbmon.exe stops working with 9.0c?? Am i doning something wrong or did you experience the same??
  15. Are you sure your text class works?? I cant even compile it: 'Spriteflags' is not a member of 'Direct3D' s.Begin(Microsoft.DirectX.Direct3D.SpriteFlags.AlphaBlend) Overload resolution failed because no accessible 'DrawText' acceps this number of arguments: TheFont.DrawText(s, text, 0, 0, cColor) I tested with both 9.0b and 9.0c...
  16. I started 8 years old. 6 years VB 6.0 and HTML combined. HTML went quite nice. VB.. eh.. made a helicopter game using image control :p nothing more... Had a VB break for 1 year, started with PHP, Made som nice scripts: LinkManager, Forums, And now im working on a CMS. Learned css. and as 15 i went back to vb trying to make some nice DX apps.. --Loffen
  17. Thanks alot both of you! :D Now as i know some efficent ways ill look deeper into vertexbuffers and code my own sprite class(?)... --Loffen
  18. My questions list: 1. What is the best map format? I have seen tilebased games use mapformats like this: MyMap;10;5 1111111111 1000000001 1002222001 1000000001 1111111111 The first line is the config line and the rest: 0 = grass, 1 = wall, 2 = water, etc..... Is this a good map format? 2. Storing maps in memory... I read in some free chapter of a book, they stored each tile in an own vertexbuffer. But somewhere else i read that they stored the whole map in a vertexbuffer and just moved the vertexbuffer or something... Whats the best way here?? 3. Displaying maps Whats the best way to display maps?? When the player moves around, should i move the map or the camera and player? 4. Players (and buildnings ?) Should i put all players/units in one vertexbuffer or in separate? If I put all players in one vertexbuffer can i still moev and rotate each of them?? Should i put all buildnings in one vertexbuffer? Some of the buildnings as 'the super automated turret' :p need to rotate a little. Can i do this if all are in one vertexbuffer?
  19. Hmm.... I believe i 'translated' it correctly. I can still 'loose my device', but when i get focus back, my cpu works very hard for about 5 sec, Then same ol error.... My new render function: Public Function RenderLoop() Dim FDeviceCoopState As Integer 'tried both this: FDevice.CheckCooperativeLevel(FDeviceCoopState) If FDeviceCoopState = ResultCode.Success Then 'and this If FDevice.CheckCooperativeLevel(FDeviceCoopState) Then Try FDevice.TestCooperativeLevel() FDevice.Clear(ClearFlags.Target, Color.Navy, Nothing, 0) FDevice.BeginScene() FRender() FDevice.EndScene() FDevice.Present() Catch ex As DeviceLostException FDevice.CheckCooperativeLevel(FDeviceCoopState) Catch ex2 As DeviceNotResetException FDevice.CheckCooperativeLevel(FDeviceCoopState) End Try ElseIf FDeviceCoopState = ResultCode.DeviceLost Then 'do nothing ElseIf FDeviceCoopState = ResultCode.DeviceNotReset Then FDevice.Reset(FPP) End If Return True End Function
  20. Next thing... :p (read all posts about 'Device Lost'): When i hit 'Alt + Tab' i change focus to VS.Net. This crashed DX. I fixed this part, it doesnt crash when loosing focus, but when it gets focus back... Public Function Render() If FDeviceLost Then If FTarget.Focus Then Try FDevice.TestCooperativeLevel() FDevice.Reset(FPP) FDeviceLost = False Catch Return False End Try End If End If Try FDevice.TestCooperativeLevel() FDevice.Clear(ClearFlags.Target, Color.Navy, Nothing, 0) FDevice.BeginScene() FDevice.EndScene() FDevice.Present() Catch Exception As DeviceLostException FDeviceLost = True End Try End Function EDIT: New dbmon pic + added FDevice.TestCoopLevel in if FTarget.Focus Then EDIT2: It seems like it cant restore the device? And the weird thing it crashes on the Application.DoEvents() line?? Suggestions?? dbmon.exe output this:
  21. The magic words i needed :p. Thanks alot! (really dunno how i could forget that one. lol) --Loffen
  22. Cant help you futher... Quite stuck my self: Cant get it workin
  23. I have tried all possible values everywhere, including that one. These values are just those i used when posting the code. I will try to call clear() like this when i come home: FDevice.clear(ClearFlags.Target, Color.Navy, nothing, 0) But in the examples (and demos) i've seen they use both 1.0F and 0.0F. Yup, 2D examples :P BTW: I want to try to make some titlebased game, dunno what settigs are optimized for that.. suggestions?? EDIT: both using 0.0f and nothing gave no results :confused: --Loffen
  24. I am not 100% sure, but try using: sprite = nothing
  25. Cant get it workin (Crashes without errors) My (VB.Net 2003) program crashes EVERYTIME i try to run it. I rewrote it a couple of times, I have read all posts from last page to page 5 (well, almost. I did exclude those not saying anything about errors). I ran some of the demos (theyre workin), I almost copyed and pasted the demo code (still no result). I am using dbmon.exe (dont understand what it want, so i attached a picture). Plus, I cant figure where the error(s) occurs, The window: opens, swaps to fullscreen (without changin color to Color.Navy), then crashes (withour errors). Form1 code: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Show() Engine = New Engine Engine.FBackBufferWidth = 1280 Engine.FBackBufferHeight = 1024 Engine.FBackBufferFormat = Format.R5G6B5 Engine.FBackBufferCount = 1 Engine.FPresentInterval = PresentInterval.Immediate Engine.FSwapEffect = SwapEffect.Copy Engine.FCreateFlags = CreateFlags.SoftwareVertexProcessing Engine.FDeviceType = DeviceType.Hardware If Engine.InitDevice(Me) Then FRunning = True End If While FRunning = True Application.DoEvents() Engine.Render() Application.DoEvents() End While End End Sub The engine: Public Class Engine Public FBackBufferWidth As Integer Public FBackBufferHeight As Integer Public FBackBufferFormat As Format Public FBackBufferCount As Integer Public FPresentInterval As PresentInterval Public FSwapEffect As SwapEffect Public FCreateFlags As CreateFlags Public FDeviceType As DeviceType Private FRoot As Manager Private FDevice As Device Private FPP As PresentParameters Private DeviceLost As Boolean Public Function InitDevice(ByVal FTarget As System.Windows.Forms.Form) FPP = New PresentParameters FPP.BackBufferWidth = FBackBufferWidth FPP.BackBufferHeight = FBackBufferHeight FPP.BackBufferFormat = FBackBufferFormat FPP.BackBufferCount = FBackBufferCount FPP.Windowed = False FPP.PresentationInterval = FPresentInterval FPP.SwapEffect = FSwapEffect FDevice = New Device(0, FDeviceType, FTarget, FCreateFlags, FPP) DeviceLost = False End Function Public Function Render() FDevice.Clear(ClearFlags.Target, Color.Navy, 1.0F, 0) FDevice.BeginScene() FDevice.EndScene() FDevice.Present() End Function End Class
×
×
  • Create New...