Author Topic: Please Help Cant draw anything  (Read 2404 times)

Offline Mikewas

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Please Help Cant draw anything
« 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

Offline D2O

  • Prof. Inline
  • *****
  • Posts: 1063
    • View Profile
    • http://www.deuteriumoxid.com
Re: Please Help Cant draw anything
« Reply #1 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
I7 2600K; 8 GB RAM ; Win10 Pro x64 | NVidia GTX 750 TI 2048MB ; Realtec OnBoard Sound;
Lenovo ThinkPad T400: XP Pro
GLB Premium-immer Aktuell

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4147
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Please Help Cant draw anything
« Reply #2 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.
I came. I saw. I played.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10708
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Please Help Cant draw anything
« Reply #3 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")

Offline Mikewas

  • Mc. Print
  • *
  • Posts: 6
    • View Profile
Re: Please Help Cant draw anything
« Reply #4 on: 2010-Jul-14 »
Thank you the file was just put into the wrong folder