Page 1 of 1

Sprite newber question

Posted: Wed Feb 17, 2016 6:39 am
by elbeardo
I'm new to sprites and trying to make a simple camera... I feel stupid asking it but what is wrong with it?

Code: Select all

SET ORIENTATION PORTRAIT

GRAPHICS

OPTION SPRITE POS NORMAL

CAMERA 1 AT BACK VIDEO

SPRITE 2 BEGIN 100,100
GRAPHICS MODE NORMAL
CAMERA 1 SNAPSHOT test
SPRITE 1 LOAD test
SPRITE 2 END
SPRITE 2 SHOW 





Re: Sprite newber question

Posted: Wed Feb 17, 2016 7:33 am
by Mr. Kibernetik
If you want to get a frame from camera footage and display it on the screen then your program can be:

Code: Select all

CAMERA 1 AT BACK VIDEO MEDIUM
PAUSE 0.1
CAMERA 1 SNAPSHOT "test.jpg"
SPRITE 1 LOAD "test.jpg"
SPRITE 1 SHOW
Here I used short pause because camera needs adjustment to light, and if you make a shot immediately after camera creation then it can have wrong brightness.

Re: Sprite newber question

Posted: Wed Feb 17, 2016 8:01 am
by Mr. Kibernetik
If you want to display camera footage on your screen then your program can be:

Code: Select all

CAMERA "cam" AT BACK VIDEO MEDIUM
SPRITE "view" BEGIN 300,300
SPRITE "view" END
SPRITE "view" SHOW
CAMERA "cam" VIEW "view"
1 GOTO 1

Re: Sprite newber question

Posted: Wed Feb 17, 2016 8:04 am
by elbeardo
Thank you!

But I thought you had to use BEGIN/END for all sprites?

Re: Sprite newber question

Posted: Wed Feb 17, 2016 8:04 am
by Mr. Kibernetik
In first example sprite is created automatically, because its size and contents is defined by loaded image.
In second example you create sprite 300x300 and use it as realtime camera display.

Re: Sprite newber question

Posted: Wed Feb 17, 2016 8:06 am
by Mr. Kibernetik
elbeardo wrote:Thank you!

But I thought you had to use BEGIN/END for all sprites?
You use begin/end if you want to create new sprite manually or if you need to draw in existing sprite.

Re: Sprite newber question

Posted: Wed Feb 17, 2016 8:17 am
by Mr. Kibernetik
Here you create new sprite "0" from image:
sprite 0 load "image.png"

Here you create new sprite "0" with size 100x100 and draw in it:
sprite 0 begin 100,100
' drawing in your sprite here
sprite end

Here you draw in existing sprite "0":
sprite 0 begin
' drawing in your sprite here
sprite end

Re: Sprite newber question

Posted: Wed Feb 17, 2016 12:01 pm
by elbeardo
Thanks, I like small examples.