GLBasic forum

Main forum => Tutorials => Topic started by: Mikewas on 2010-Jul-14

Title: Please Help Cant draw anything
Post by: Mikewas on 2010-Jul-14
 :'( :'( I am just learning basic but I know and love c and when I type an example that loads, draws, sprite then shows the screen it is still black I cant get any new type of project like that to work

any help is appreciated Thank You
Title: Re: Please Help Cant draw anything
Post by: D2O on 2010-Jul-14
Quote from: Mikeway on 2010-Jul-14
:'( :'( I am just learning basic but I know and love c and when I type an example that loads, draws, sprite then shows the screen it is still black I cant get any new type of project like that to work

any help is appreciated Thank You


Hello,

can you post a code example ?

I think you have forget "showscreen"

Code (glbasic) Select

While true
// Drawsprite........

Showscreen    // <<<<<<<<<<< ????

wend
Title: Re: Please Help Cant draw anything
Post by: Ian Price on 2010-Jul-14
Firstly are you sure you are loading the sprites? GLBasic doesn't give MAV (like Blitz) or warn you that an image hasn't loaded. Ensure you are using the right file path

A simple test would be to use the PRINT command during your sprite drawing loop.

First you'll need to create a bitmap (.BMP) image (I used 32x32 in MSPaint) and place it in the "app/media/" directory that is automatically created when you create your project.


Code (glbasic) Select

SETCURRENTDIR("Media")

LOADSPRITE "sprite.bmp",1

// Set screen resolution
SETSCREEN 640,480,0

// Draw a white box
DRAWRECT 0,0,32,32,RGB(255,255,255)

// Grab the white box and store is as a sprite image. This is for control purposes, like a science experiment.
GRABSPRITE 2,0,0,32,32

// Keep running this loop until you press ESC
WHILE TRUE

// Deos what it says - prints "HELLO" on the screen"
PRINT "HELLO",10,10

// Draw the loaded sprite (if creates/exists)
DRAWSPRITE 1,160,100

// Draw the "control" sprite - the white box
DRAWSPRITE 2,200,100

// Refeshes the screen
SHOWSCREEN

// Ends the loop
WEND


This test will if run correctly show the "HELLO" text, the loaded graphic image and a grabbed graphic image - white block.

You can run this without creating an .BMP image and it will still display something (HELLO and white box) rather than a blank screen, however if you don't supply an image, you won't know if you are loading the sprite properly or not.
Title: Re: Please Help Cant draw anything
Post by: Kitty Hello on 2010-Jul-14
If a sprite is not loaded, you get some LASTERROR$ I thing. But who cares.
Try DRAWRECT first, then be sure your bmp is in the .app directory (or the .app/Media and load with "Media/my.bmp")
Title: Re: Please Help Cant draw anything
Post by: Mikewas on 2010-Jul-14
Thank you the file was just put into the wrong folder