Help with actions detect in RPG map
Blitz3D Forums/Blitz3D Beginners Area/Help with actions detect in RPG map
| ||
I am using a 1024 by 1024 image using 16 colours colour map ( under_scene) under a 1024 by 1024 scene. Here is the heart of the system. The get Z .................................... Function get_z() DrawImage under_scene,0,0 ;used as a zone map Local mx,my mx=screen_x+352 ; used to offset under_scene and scene my=screen_y+352 ; " " " " GetColor mx,my r=ColorRed() g=ColorGreen() b=ColorBlue() z=0 If r=128 And g=0 And b=0 Then z=1 ; dark red If r=0 And g=128 And b=0 Then z=2 ; dark green If r=128 And g=128 And b=0 Then z=3 ; dark yellow If r=0 And g=0 And b=128 Then z=4 ; very dark blue If r=128 And g=0 And b=128 Then z=5 ; purple If r=0 And g=128 And b=128 Then z=6 ; Teal If r=192 And g=192 And b=128 Then z=7 ; light gray If r=128 And g=128 And b=128 Then z=8 ; dark gray If r=255 And g=0 And b=0 Then z=9 ; bright red If r=0 And g=255 And b=0 Then z=10 ; bright green If r=255 And g=255 And b=0 Then z=11 ; light yellow If r=0 And g=0 And b=255 Then z=12 ; dark blue If r=255 And g=0 And b=255 Then z=13 ; cerise If r=0 And g=255 And b=255 Then z=14 ; cyan If r=255 And g=255 And b=255 Then z=15 ; white End Function .............................. z is returned with whatever colour is at mx,my on the under_scene After a cls, the upper graphic is put on the screen, then the HUD and hero, which means that I can detect invisible zones, almost to a pixel. My little hero stays in the centre of the screen while the scene and under scene are scrolled in the HUD. But.. I cannot get the "active area" under the hero's feet . The maths escape me, and I have tried for quite a while to get my brain around it. Any help appreciated. Dicon This works well on static scenes, ( I CAN figure that one ) but I would like to scroll. |
| ||
I didn't understand your description. Please post a screenshot with your scene structure. I advise you to compute all these 'z' values into a 1024x1024 integer array at the beginning of the level. Then it'd be a matter of referencing this array to get the values, without needing a function and computing anything real-time. ThisZ = SceneZ(X, Y) Last edited 2011 |
| ||
it is never the map, that scrolls under the hero, but the virtual camera moves on the map! this means, that also your hero should move in this pixel-system coordinates. let change his x to x-1, if he walkes to the left, changes his x to x+1, if he moves to the right,... at the end it comes to drawing. Now is the moment for virtual camera. Before drawing the scene, subtract the position of the player have a look on this two fundamental codes: Graphics 400,400 Repeat CamX=CamX+1 Cls Color 1,99,1 For I=0 To 30 Rect (i*30)-CamX,101,29,29 Next Flip 1 Forever move this player with the arrow-keys: Graphics 400,400 SetBuffer BackBuffer() Global Player_X#=500 Global Player_Y#=500 Const KEY_LEFT=203 , KEY_RIGHT=205 ,KEY_UP=200 ,KEY_DOWN=208 FPS=CreateTimer(60) Repeat ; control the player If KeyDown(KEY_LEFT) Player_X =Player_X - 0.5 If KeyDown(KEY_RIGHT) Player_X=Player_X + 0.5 If KeyDown(KEY_UP) Player_Y=Player_Y - 0.5 If KeyDown(KEY_DOWN) Player_Y=Player_Y + 0.5 Cls ; camera For Player CameraPicture (Player_X-200 , Player_Y-200, 0) ;some painting To have the feeling of a monitor: Color 111,111,111 Rect 0,0,900,30 Rect 0,370,900,30 Rect 0,0,30,400 Rect 370,0,160,400 Flip 0 WaitTimer fps Forever Function CameraPicture (CamX, CamY, OffX) Color 1,99,1 ; simulates a moving ground Floor For j=0 To 90 For I=0 To 90 RealX=i*30-CamX+1 If RealX>0 And RealX<400 Rect OffX + (i*30)-CamX , (j*30)-CamY , 29,29 EndIf Next Next ; the player: Color 0,0,255 Oval OffX + Player_X-CamX , Player_Y-CamY ,15,15 End Function You see, that the 'virtual camera'-positon is always -200/-200 from the player. And this value has to be subtracted when painting all scene-objects Last edited 2011 |