|
Post by n00b on May 28, 2019 5:30:09 GMT -6
No. RCBasic does not currently support that.
|
|
|
Post by drfloyd on May 28, 2019 5:49:08 GMT -6
ok
the images are considered numbers 0 to 4096 ? it's a problem if i want to use ARRAY for naming the images
in BLITZ i can do that :
dim dessinsystem(17) dim dessinship(3) for i=0 to 17 dessinsystem(i)=loadimage("media/system"+str(i)+".png") next for i=0 to 3 dessinship(i))=loadimage("media/ship"+str(i-50)+".png") next
Not possible with RC. I should do that :
dim dessinsystem[18] dim dessinship[4] for i=0 to 17 loadimage (i,"media/system"+str(i)+".png") dessinsystem=i next for i=50 to 53 loadimage (i,"media/ship"+str(i-50)+".png") dessinship[i-50]=i next
I am right or not ?
|
|
|
Post by tbird on May 28, 2019 6:26:46 GMT -6
....ha deleted my post, my brain wasnt working yet.....disregard lol
|
|
|
Post by n00b on May 28, 2019 6:34:52 GMT -6
You are mostly right.
Your code:
dim dessinsystem[18] dim dessinship[4] for i=0 to 17 loadimage (i,"media/system"+str(i)+".png") dessinsystem=i next for i=50 to 53 loadimage (i,"media/ship"+str(i-50)+".png") dessinship[i-50]=i next
Correction (You only had 1 line that was wrong):
dim dessinsystem[18] dim dessinship[4] for i=0 to 17 loadimage (i,"media/system"+str(i)+".png") dessinsystem[i]=i '<-----You forgot your bracket for your array next for i=50 to 53 loadimage (i,"media/ship"+str(i-50)+".png") dessinship[i-50]=i next
|
|
|
Post by n00b on May 28, 2019 6:38:14 GMT -6
I would also recommend either using a global variable to track the last image slot loaded or use ImageExists() in a loop to check for an open image slot.
|
|
|
Post by drfloyd on May 28, 2019 9:23:41 GMT -6
I have followed your advice :
noim=-1
for i=1 to 18 noim=noim+1 loadimage (noim,"media/systeme"+str(i)+".png") dessinsysteme=noim next
for i=1 to 3 for j=1 to 6 noim=noim+1 loadimage (noim,"media/galaxie"+str(i)+"_"+str(j)+".png") dessingalaxie[i,j]=noim next next
for i=1 to 4 noim=noim+1 loadimage_ex (noim,"media/vaisseau"+str(i)+".png",rgb(0,0,0)) dessinvaisseau=noim next
so it is flexible and can insert images where i want, whitout "hole" ! Great.
But i am very curious : i am i little surprise with this systeme of 0-4096 numbersfor the images... With SDL or BLITZ I can do that very easy by matching directy the array variable to the image
for i=1 to 17:dessinsysteme=loadimage("data/systeme/systeme"+str(i)+".png"):next for i=1 to 4:dessinvaisseau=loadimage("data/vaisseau/vaisseau"+str(i)+".png"):next etc.....
Is there a special reason of this difference ? Because perhaps you consider that RCbasic game do no need a lot of images (arcade games) ?
|
|
|
Post by tbird on May 28, 2019 11:05:24 GMT -6
The 4096 is for the image slots, not the images that you are drawing, you can have 4000 images of slot 1, or 50 images drawn from slot 32 etc... I hope this is what you were asking about.
|
|
|
Post by drfloyd on May 28, 2019 12:29:53 GMT -6
4000 images of slot 1 ?
|
|
|
Post by n00b on May 28, 2019 13:31:38 GMT -6
But i am very curious : i am i little surprise with this systeme of 0-4096 numbersfor the images... With SDL or BLITZ I can do that very easy by matching directy the array variable to the image
for i=1 to 17:dessinsysteme=loadimage("data/systeme/systeme"+str(i)+".png"):next for i=1 to 4:dessinvaisseau=loadimage("data/vaisseau/vaisseau"+str(i)+".png"):next etc.....
Is there a special reason of this difference ? Because perhaps you consider that RCbasic game do no need a lot of images (arcade games) ?I don't really know much about Blitz but your example code here, while it is valid, is not at all useful in sdlBasic. The LoadImage() function will return an image slot in sdlBasic but what you are doing here is losing the reference to your last image slot each time through the loop. Ideally you would probably want dessinsysteme and dessinvaisseau to be arrays. RCBasic does not have optional arguments like sdlBasic does but you could write your own image loading function that loads an image in the next available image slot very easily. To clarify what TBird said, you can load an image once and draw it on the screen as many times as you want. More importantly, you can load 1 image as a sprite sheet and draw different frames of that sprite from one sheet. And once you are done with an image, you can use the DeleteImage() function to free that memory slot so you can reuse it for another image. If you manage your resources you could create any game you want and probably never even use 100 slots.
|
|
|
Post by drfloyd on May 29, 2019 0:32:42 GMT -6
Sorry, I of course forgot the array : for i=1 to 17:dessinsysteme(i)=loadimage("data/systeme/systeme"+str(i)+".png"):next for i=1 to 4:dessinvaisseau(i)=loadimage("data/vaisseau/vaisseau"+str(i)+".png"):next
I understand that RC does not have optional arguments to do that (NAALAA is the same) and that we should manage the slots
|
|
|
Post by drfloyd on May 30, 2019 3:29:41 GMT -6
|
|
|
Post by n00b on May 30, 2019 9:24:31 GMT -6
drfloyd I will check it out as soon as I get home tonight.
|
|
|
Post by drfloyd on May 31, 2019 13:44:16 GMT -6
Hello
My new question :
How to empy the keyboard buffer ?
I use key(return), but on the next screen, Return is still in the buffer
thanks
|
|
|
Post by tbird on May 31, 2019 20:17:33 GMT -6
Return will not stay in the buffer it is either key down or key up. The problem I believe the problem you are having is you need a Key timer.
Example:
DIM keyTimer DIM keyDelay
keyTimer = Timer() keyDelay = 200 '200 ms
If Key(K_RETURN) And Timer() - keyTimer > keyDelay Then FOO() keyTimer = Timer() End If
|
|
|
Post by drfloyd on Jun 1, 2019 1:34:16 GMT -6
Indeed, it is not a problem of buffer... I just understood that KEY is a KEY PRESS function and not a KEY HIT function.... Some Basics offer the both So In fact RCBASIC is miising a second KEY function : "KEY_HIT" Thanks for your solution, it works.. I have also try this, it work, but not very good (sometimes key press is not recognized) : If Key(K_RETURN) then wait(200) update() FOO() end ifJust wait(200) do not work at all.... I don't know why ? ... i should add update()... mysterious for me n00b, there is no other simply solution ?
|
|