Graphics flip drawing help
BlitzMax Forums/BlitzMax Beginners Area/Graphics flip drawing help
| ||
Hi all. I have been using blitzmax a few weeks now and slowly i am getting my game done. I was hope to get some help about the use of grapihics in blitzmax. The help file does not realy go into detail about how to use the Flip/Hooks and drawing grapics on a layer or just drawing them once. I read something about opengl but then you have to adress the graphics stuff dirrant and i could not find any thing about those commands. Here is my problem and wat i want to achieve I want the gameloop to display all objects pictures first i load all the PictursFille names in to an AllPictures array A game grid will be used to link/Represent game objects data/img For instance 1 is a wizzard and 5 a goblin I fill up the game grid X,Y randome value Next i use my function update map, This loops troug the gamegrid X,Y it draws the picture on screen at X*50Y*50 using my function Drawme I use these functions in my main loop If i start the game the pictures are all onscreen but is is realy slow. i have a img (selection Box) that is put at the positoin at the mouse if i use Drawme directly it is fast. I know it has someting to do whit the functions loops But i cant add an IF statment to a Function becuase it will not work i tried to add a IF Updatemap=done do "nothing" it just keeps saying end of file. I tried using a while X=2 update map wend X=0 do "nothing" I realy could use some information on how to use Graphics and Flip 1/0 Hooks and how to create layers and Clear only particual objects instead of the whole screen below are the scirpts i uses The drawme function Function DrawMe(Objectref:Int,X:Int,Y:Int) Local Picture:TImage=LoadImage("C:\GameBuild\WizzardGame\Objects\"+AllPictures[Objectref],FILTEREDIMAGE+MASKEDIMAGE) DrawImage Picture,X,Y End Function Update map code (CellGrid is the GameGrid) Function Updatemap(Refresh:Int) Local x;Local y While Refresh=2 For X = 1 To 25 For Y = 1 To 13 Drawme CellGrid[X,Y],X*50,Y*50 Next Next Wend And the main game loop RandomMap Local Z=2 Repeat Local gamechange:Int SetScale( 2,2 ) SetClsColor 050,025,025 Cls ResetCollisions Local grid=25*2 Local Subgrid=Grid/5 Local pargrid=subgrid/5 Local MX= MouseX() /grid*grid Local MY= MouseY() /grid*grid Updatemap(Z) 'Local AllObjectPic:TImage=LoadImage(ImgString$,MASKEDIMAGE) DrawText "WizzGameEngine 0.1",25,10 'Load all images to game DrawImage StBox,MX,MY Z=2 Flip 0 Until KeyHit(key_escape) End Thanks in advance |
| ||
You should load all the images before the main loop. Loading images take time, drawing them is fast. If you have several images, you could preload them into a TImage array and then index whichever image you need. Global Images:TImage[TotalNumberOfImages] Function InitImages() For Local i:int = 0 Until TotalNumberOfImages Images[i] = LoadImage(AllPictures[i],FILTEREDIMAGE+MASKEDIMAGE) Next End Function Redo Drawme as such Function DrawMe(Objectref:Int,X:Int,Y:Int) Local Picture:TImage=Images[Objectref) DrawImage Picture,X,Y End Function in your main loop, you can place Local AllObjectPic:TImage=LoadImage(ImgString$,MASKEDIMAGE) Line above the Repeat. If there is a chance the ImgString$ variable will change within the loop, then use an image array like before. |
| ||
Thank you TomToad! It works fine now. Is there any indepth documentation about using graphics whit blitzmax you know of? |
| ||
Hi Wizard, in what way ? I'm pretty familiar with BlitzMAX graphics in many areas. What are you trying to achieve and do in your code ? |
| ||
Hi, Dw817 i did not knew you replied to my topic the code works now and i did not visit the forum in a long time. The indepth documentiion i asked for is like how can i make my world biger than the window and add scrolling. How do fliphooks realy work how do you make layers that are drawn in depdenlty(i figure flip draw from the back to front layer) how to create animted objects or images. The basic blitzmax help file is realy short. I now know using setcolor\scale must be inside a object type or it changes all drawings The game is going good as i have been busy a week now. The qeuter finaly felt |
| ||
I now know using setcolor\scale must be inside a object type or it changes all drawings No? You need to undo your changes. If you know the values skip backup... else backup them getcolor() and getscale... Else you run into trouble if you draw something which draws children which itself adjust colors, alpha, scale... Bye Ron |
| ||
I c So for every object/image i first get then i set. Afther my manipulation is done i reset it to normal. so for the next i do this again. and so on Any how about the documentation i few more qeustion rise How do i make lighting effects? for instane i have a (2d) wall and i shoot my lazer next to it how do i get the color effect to change whitin a given raduis? |
| ||
@ get set If you know, that the follow up things are not changing colors, you could skip "set oldvariables". It is a matter of whether you want to save some small instructions or not. @ lighting Use different blend modes and a nicely done sprite containing an alpha channel (the "glow" is not opaque but slightly transparent). bye Ron |