More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites. More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
Go Back  Xtreme Visual Basic Talk > > > > More effective way of rendering 2d sprites.


Reply
 
Thread Tools Display Modes
  #1  
Old 12-31-2006, 11:46 PM
psychotomusSim psychotomusSim is offline
Centurion
 
Join Date: Apr 2006
Posts: 192
Default More effective way of rendering 2d sprites.


I'm creating a 2d game and i'm trying to upgrade my engine from vb6 to .NET 2005 express.
it just freezes the window.
my header
Code:
    Structure Textures
        Dim TextureRefNum As Integer
        Dim Render As Boolean
        Dim TheSprite As Sprite
        Dim X As Integer
        Dim Y As Integer
        Dim trigger As String
        Dim color As Long
        Dim layer As Integer
        Dim Objects() As Textures
    End Structure

    Dim Map(500, 500) As Textures

how i create every sprite (only created once)
Code:
Map(x1, y1).TheSprite = New Sprite(GraphicsDevice)
my render function
Code:
       Dim x As Integer
        Dim y As Integer
        'Clear the screen black
        GraphicsDevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0F, 0)

        'All drawing goes in between the BeginScene and EndScene statements
        GraphicsDevice.BeginScene()

        For x = 0 To 500
            For y = 0 To 500
                If Map(x, y).render = True Then
                    Map(x, y).TheSprite.Begin(SpriteFlags.AlphaBlend)
                    Map(x, y).TheSprite.Draw2D(Texturess(0), Point.Empty, 0.0F, New Point(Map(x, y).X, Map(x, y).Y), Color.White)
                    Map(x, y).TheSprite.End()
                End If
            Next
        Next

        GraphicsDevice.EndScene()

        'present all graphical information to the user’s screen
        GraphicsDevice.Present()
__________________
Game Maker Forums - Game Programming Forums
Online RPG Creator - Create your own Web Game
Reply With Quote
  #2  
Old 04-19-2007, 07:06 PM
dadevil's Avatar
dadevil dadevil is offline
Freshman
 
Join Date: Oct 2004
Location: Michigan
Posts: 27
Default

As I've been reading, there are a lot of different ways to draw 2s sprites. I'm not familiar with all of them but this is how I did mine.

Code:
Dim mDevice As Device Dim mSprite As Sprite Dim mSprites As New Collections.ArrayList() Public Sub Load() For x As Integer = 0 To 500 For y As Integer = 0 To 500 mSprites.Add(New cSprite("c:\blah.jpg", Left, Top)) Next Next End Sub Public Class cSprite Private mTexture As Texture = Nothing Private mRectangle As Rectangle Private Center As New Vector3(1, 0, 0) Private Position As Vector3 Public Sub New(ByVal File As String, ByVal aLeft As Integer, ByVal aTop As Integer) Position = New Vector3(aLeft, aTop, 1) mTexture = TextureLoader.FromFile(mDevice, File) Dim s As Surface = mTexture.GetSurfaceLevel(0) Try Dim mSurfaceDescription As SurfaceDescription = s.Description mRectangle = New Rectangle(0, 0, mSurfaceDescription.Width, mSurfaceDescription.Height) Finally s.Dispose() End Try End Sub Public Sub Render() mSprite.Draw(mTexture, mRectangle, Center, Position, Color.White) End Sub

Then call it with something like this:

Code:
Public Sub MainRender() mDevice.BeginScene() mSprite.Begin(SpriteFlags.AlphaBlend) For Each x As cSprite In Sprites x.Render() Next mSprite.End() mDevice.EndScene() mDevice.Present() End Sub
__________________
"Whoa, if that's true maybe we can link up to someone who's meditating and download enlightenment" - Tachikoma
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites. More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites. More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
 
More effective way of rendering 2d sprites.
More effective way of rendering 2d sprites.
 
-->