[Gambas-user] Character movement game help
Fabien Bodard
gambas.fr at ...626...
Wed Feb 18 10:17:07 CET 2015
A gridvew .. for a game ? well two ears ready to kevin. He is the boss
here for games on Gambas ;-P
2015-02-18 8:50 GMT+01:00 Kevin Fishburne <kevinfishburne at ...1887...>:
> On 02/18/2015 01:04 AM, Jair Yunis wrote:
>> Alohaaa :)
>>
>> I am working on a little game and just started creating the environment in
>> which the chracter moves around, that creates itself randomly as it is
>> discovered,
>> now, the thing is i want to make it in this particular way, but makes the
>> movement pretty much rough,
>> any ideas on how to make it smoother??? avoid lag and staff???
>>
>> The main for has only a Gridview (H455 x W483)
>> and then 3 pictues (32 x 32) water.png, grass.png and forest.png added to
>> data
>
> I would use the SDL and OpenGL components with orthogonal projection,
> which would make the graphics 2D and give you precise control over the
> size and placement of tiles/quads. The graphics code can remain distinct
> from the "main" code and yield smooth results by interpolating between
> "current" and "target" versions of key variables. I can provide code
> samples from my project if you need help "setting up" or using OpenGL in
> GAMBAS. For example:
>
> Public Screen As New Window As "Screen" ' Render window SDL surface.
>
> ' Create client's screen.
> With Screen
> .FullScreen = False
> '.Framerate = 60
> .Resizable = False
> End With
>
> ' Show screen.
> Screen.Show
>
> ' Enable 2D textures.
> Gl.Enable(Gl.TEXTURE_2D)
>
> ' Set up alpha blending.
> Gl.Enable(Gl.BLEND)
> Gl.BlendFunc(Gl.SRC_ALPHA, Gl.ONE_MINUS_SRC_ALPHA)
>
> ' Set texture environment mode.
> Gl.TexEnvi(Gl.TEXTURE_ENV, Gl.TEXTURE_ENV_MODE, Gl.MODULATE)
>
> ' Enable backface culling.
> Gl.Enable(Gl.CULL_FACE)
>
> ' Set shading model.
> Gl.ShadeModel(Gl.SMOOTH)
>
> ' Enable lighting.
> Gl.Enable(Gl.LIGHTING)
> Gl.LightModelfv(Gl.LIGHT_MODEL_AMBIENT, [0, 0, 0, 0])
> Gl.Enable(Gl.LIGHT0)
>
> ' Enable normal normalization so scaled objects are lit correctly.
> Gl.Enable(Gl.NORMALIZE)
>
> ' Set up the gamepad.
> PadDevice = Exec ["cat", "/dev/input/js0"] For Read As "Gamepad"
>
> ' Set audio channels.
> Channels.Count = 32
>
> ' Play loading screen music.
> Music.Load("music/LOADING.wav")
> Music.Volume = 0.5 * MusicScale
> If PlayMusic Then Music.Play(0, 0)
>
> Public Sub SpritePixel(ScreenX As Integer, ScreenY As Integer, Width As
> Integer, Height As Integer, Centered As Boolean, SpriteScale As Integer)
>
> ' Draw specified sprite.
>
> ' Adjust position and size by sprite scale.
> ScreenX *= SpriteScale
> ScreenY *= SpriteScale
> Width *= SpriteScale
> Height *= SpriteScale
>
> ' Check if sprite is centered.
> If Centered Then
> ' Center sprite coordinates.
> ScreenX -= Width / 2
> ScreenY -= Height / 2
> Endif
>
> ' Create the textured quad.
> Gl.Begin(Gl.QUADS)
> ' Bottom-left vertex.
> Gl.TexCoord2f(0, 1)
> Gl.Vertex2f(ScreenX, ScreenY + Height)
> ' Bottom-right vertex.
> Gl.TexCoord2f(1, 1)
> Gl.Vertex2f(ScreenX + Width, ScreenY + Height)
> ' Top-right vertex.
> Gl.TexCoord2f(1, 0)
> Gl.Vertex2f(ScreenX + Width, ScreenY)
> ' Top-left vertex.
> Gl.TexCoord2f(0, 0)
> Gl.Vertex2f(ScreenX, ScreenY)
> Gl.End()
>
> End
>
> Hopefully this helps. I also have code to load textures from disk,
> convert them to OpenGL textures and map them to quads. I don't recommend
> using Qt or GTK objects for graphics; OpenGL is the way to go for
> consistency and control.
>
> --
> Kevin Fishburne
> Eight Virtues
> www: http://sales.eightvirtues.com
> e-mail: sales at ...1887...
> phone: (770) 853-6271
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
--
Fabien Bodard
More information about the User
mailing list