Graphics for a game

Game development specific discussions.
Post Reply
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Graphics for a game

Post by datwill310 »

Hi all.

Today, I have been inspired by a YouTube channel to create a game for them to play. They have come up with the basic idea, and I have added a few of my own. It's coming along really well! Out of all the games I have thought up, this is definitely the best thought through - I gotta give credit to the YouTube channel for that one! Planning the game isn't the issue.

I have attempted to craft games before with a few languages, but never before to this degree. I intend for the game to run on a solid 2D platforming engine. I require an equally solid, fast graphics back-end for my game. I'm positive that GFX is good, since I know that a few users of computers may have issues with OpenGL (I used to, as some of you may know!).

One major flaw with my previous game attempts is that they would run the simplest of animations really slowly. I'm talking a single image, I'll admit relatively large, but not massive, and moving it onto the screen from the outside of the screen: think of scrolling the logo onto the screen. It tells me a few things: either,
  • My algorithm was not efficient enough. This is most probably the case: I used sleep and then (when that didn't really work) timer to count milliseconds and after a certain time, the screen would be cleared and the screen redrawn (in the case of my logo). This was slow: anything below, like 50ms becomes glitchy and aesthetically unpleasing indeed, and 50ms was too slow for my aim: it took several seconds for the animation to finish at such a time.
  • OR GFX isn't good enough? I highly doubt this option since I've seen a few tutorials using the GFX "default" back-end and the animations worked mavelously. Perhaps I should look over how they worked!
I would appreciate some help as to what graphics back-end I should use for my 2D platformer. GFX and OpenGL is about all I know of, and I know next to nothing about them either. Also any help with animation and FB would be a big help (I know how to capture input from user with numerous devices: I have made very simple games where I/O works very well).

Thanks for your time.

EDIT:

Been looking a bit at the pinned library links page. I would like to use the PNG format for less data hogging. FreeImage seems a suitable choice.
FMOD too looks amazing to create sound effects. The webpage seemed a bit confusing though: is it a piece of software or a DLL or both?!
Boromir
Posts: 463
Joined: Apr 30, 2015 19:28
Location: Oklahoma,U.S., Earth,Solar System
Contact:

Re: Graphics for a game

Post by Boromir »

Animation can be done in FB_GFX. I've animated a 640x480 image set with sleep. Maybe post some code?
OpenGl will probably be faster then FB_GFX and most computers can use it. I have an old windows 98 pc and it runs opengl fine. I generally just use FB_GFX. It suits all my needs.
datwill310 wrote:FMOD too looks amazing to create sound effects. The webpage seemed a bit confusing though: is it a piece of software or a DLL or both?!
It has a DLL but to use it you will need the fb headers.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Graphics for a game

Post by datwill310 »

Boromir wrote:Animation can be done in FB_GFX. I've animated a 640x480 image set with sleep. Maybe post some code?
OpenGl will probably be faster then FB_GFX and most computers can use it. I have an old windows 98 pc and it runs opengl fine. I generally just use FB_GFX. It suits all my needs.
datwill310 wrote:FMOD too looks amazing to create sound effects. The webpage seemed a bit confusing though: is it a piece of software or a DLL or both?!
It has a DLL but to use it you will need the fb headers.
If you don't mind providing some example code, that would be a big help. I think I'll go with GFX: OpenGL is dependent on hardware, and I have experienced those pains (I guess GFX is hardware-dependent too? lol).
As for FMOD, I think I'll just use the software and save my sounds etc. Seems a lot simpler to implement that way.
Boromir
Posts: 463
Joined: Apr 30, 2015 19:28
Location: Oklahoma,U.S., Earth,Solar System
Contact:

Re: Graphics for a game

Post by Boromir »

This code needs a 640x480 image set named like this.
img1.bmp
img2.bmp
img3.bmp

It plays them while bouncing the animation around the screen.

Code: Select all

Const wtime=0.1 'Amount of time to wait between frames in seconds
Const frames=3' number of images in the animation. Just change this and it will add more frames to the animation. You'll have to draw them of course.

ScreenRes 1280,1024,32

Dim As Any Ptr img(frames-1)

Dim As Integer x,y,dx=1,dy=1,i
Dim As Double ol_time

For i=0 To UBound(img)
	img(i)=ImageCreate(640,480)
	BLoad "img"+Str(i+1)+".bmp",img(i)
Next i

i=0
Do
ScreenLock
Cls
Put(x,y),img(i),alpha
ScreenUnLock

x+=dx
y+=dy
If x>1280-640 Or x<0 Then dx=-dx
If y>1024-480 Or y<0 Then dy=-dy
If Timer>ol_time+wtime and i<UBound(img) Then i+=1:ol_time=Timer
If Timer>ol_time+wtime and i=UBound(img) Then i=0:ol_time=Timer

Sleep 1

Loop Until MultiKey(1)
Last edited by Boromir on Apr 05, 2017 14:41, edited 1 time in total.
datwill310
Posts: 355
Joined: May 29, 2015 20:37

Re: Graphics for a game

Post by datwill310 »

Boromir wrote:This code needs a 640x480 image set named like this.
img1.bmp
img2.bmp
img3.bmp

It plays them while bouncing the animation around the screen.

Code: Select all

Const wtime=0.1 'Amount of time to wait between frames in seconds
Const frames=3' number of images in the animation. Just change this and it will add more frames to the animation. You'll have to draw them of course.

ScreenRes 1280,1024,32

Dim As Any Ptr img(frames-1)

Dim As Integer x,y,dx=1,dy=1,i
Dim As Double ol_time

For i=0 To UBound(img)
	img(i)=ImageCreate(640,480)
	BLoad "img"+Str(i+1)+".bmp",img(i)
Next i

i=0
Do
ScreenLock
Cls
Put(x,y),img(i)
ScreenUnLock

x+=dx
y+=dy
If x>1280-640 Or x<0 Then dx=-dx
If y>1024-480 Or y<0 Then dy=-dy
If Timer>ol_time+wtime and i<UBound(img) Then i+=1:ol_time=Timer
If Timer>ol_time+wtime and i=UBound(img) Then i=0:ol_time=Timer

Sleep 1

Loop Until MultiKey(1)
Good piece of code! I'll edit it to use PNG images in my game.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Graphics for a game

Post by D.J.Peters »

with fbImage you can load png, jpg, bmp, pcx, dds ...

Joshy
Post Reply