Hello, I have just started GL-BASIC for game development, and I would like to buy it if I can get used to it. I wrote a little code this morning, however it would not display my sprite
START:
LOADBMP "E:/Background.bmp"
MAIN:
LOADSPRITE 0, "E:/Player.bmp"
DRAWSPRITE 0, 100, 100
SHOWSCREEN
KEYWAIT
I am 99.9% sure my path is correct, my background shows
First off, I would get rid of all direct access - directly specifying a drive letter is baaaddd...
Once you end up with :
START:
LOADBMP "Background.bmp"
MAIN:
LOADSPRITE 0, "Player.bmp"
DRAWSPRITE 0, 100, 100
SHOWSCREEN
KEYWAIT
note that the parameters for LOADSPRITE are the wrong way around.
It should be LOADSPRITE "Player.bmp",0
Then check to make sure that the graphics are in the same place as the executable.
Hi James,
you might also want to have a look at the SETCURRENTDIR() command!
:)
Best,
P.
If your running on anything else but Windows, keep an eye on file name case sensitivity too. ;)
:help:
Here, see my attached project! It will help you understand a basic loop in GLBasic. It loads a background and a sprite, and even deals with mouse coordinates! Please let me know if you don't understand part of it.
You wrote
LOADBMP "E:/Background.bmp"
But you shouldn't use drive letters, since they sometimes change depending on PC, try with:
LOADBMP "../Background.bmp"
each ".." means "back to folder" so if your app.exe is inside of C:\Users\Me\app.exe
and your Background image is on C:\Users\Background.bmp
Try placing ".." without quotes before the file name as above, if your image is in the same folder as your app.exe then write only filename, if your background image is in a further folder than your app.exe, example:
C:\Users\Me\images\Background.bmp
Then use:
LOADBMP "images\Background.bmp"
These should not be used:
LOADSPRITE 0, "E:/Player.bmp"
DRAWSPRITE 0, 100, 100
Since these commands are only for LOADSPRITE, ZOOMSPRITE, ROTOZOOMSPRITE and STRETCHSPRITE
You should better check out STRETCHSPRITE, for me, it is better because when using STRETCHSPRITE you can change width and height.
LOADSPRITE "Background.bmp", id // id is any positive number
DRAWSPRITE id, x, y // x, y positions
x=100
y=200
To use the image as background use this:
GETSCREENSIZE sx, sy
LOADSPRITE "Background.bmp", 0
STRETCHSPRITE 0, 0, 0 sx, sy // first 0 is id, next ones are start x/y positions, then sx/sy are final positions.
GETSCREENSIZE returns the screen resolution for your app (as specified in project options) and places it in the variables sx## and sy##.
Do not forget to use SHOWSCREEN, i always do :D
Also, you should check out the SETCURRENTDIR(); command :)
Press F1 while using GLBasic SDK :)
also uses the "Media" folder to put on your files, which is the most correct way to and add a SETCURRENTDIR("Media") near the top. All files for compatible sake should been in the Media folder for games.
A big handy tip for all new users.
Part of your code not doing what you want it to do in run time? Place the END command inside your IF/ENDIFs that seem to be ignored in your running project. ( Or SUBs & FUNCTIONs )
Run your code & if it exits at the given point where your mysterious IF/ENDIF was checked you`ll know its being read but misinterpreted. Go back and look at what youve coded to happen, then step backwards and look at whats leading to it being ignored.
Its also handy to have a pen and pad handy. Pen and paper can save lots of time by scribbling down your plan and formulating that into code later on screen. When it doesnt work - look at what you penned down.
If the search option here fails to help you just ask as there are many here who can help you.
so much help , but no reply :noggin:
:D
Quote from: Marmor on 2013-Sep-28
so much help , but no reply :noggin:
yeeeah I've come to expect that. Most times when new people post for help, they take the help and run. lol.
It's about persistence. We humans often lack it :-)
Youth: Oh cool, a new programming language! Oh, I have to see this movie! Wait, you are going to the burger-place? GIRLS! (or BOYS!)
10 years later they come back to programming having kids and a job and about 10 minutes of free time in the evenings :-)
But....after these ten years he can display the sprite...
And in a world of 4D in future he create a new game genre and become a millionaire.
Quote from: Heiko on 2013-Oct-11
But....after these ten years he can display the sprite...
And in a world of 4D in future he create a new game genre and become a millionaire.
Like Notch :o
Hillarious! :good: