Qbasicnews.com
April 12, 2021, 06:44:46 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Panning...  (Read 10066 times)
Foolish__1
New Member

Posts: 21


« on: June 02, 2005, 02:31:54 PM »

Hey all,

I have a bit of what many of you would call a 'basic' question...  Sigh.  I'm tring to make an RPG (how unique, en?) and I want it to pan, none of the Zelda style walk to the edge of the screen and get pushed over.  So, any-hoo, the game is obviously made up of tiles.  Now, I've run some 'tests' (I.E. made a program that did exactly this)  and the way it worked is if you pused, say 'up' It would load the tiles that were one row above the area you were in and slowly slid the whole thing down.  Now this system works fine BUT when you push 'UP' there is a small delay (as it loads the tiles into memory and such).  This is only a problem when holding up to keep walking up.  It's a very jerky walk.

I've done this kinda of stuff in C and it was done using a massive virtual buffer that first loading the entire map/town/dungeon/whatever and, well, you guys know how that works.  Any way, how do I do that in FB?  What's the best way to do something like this in FB?

My second question, what do VIEW and WINDOW do and how do they work?  I just don't get them at all?  It there a good command reference somewhere?

Thanks all!

-Pauli
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
SotSvart
Member
*
Posts: 61



WWW
« Reply #1 on: June 02, 2005, 03:02:19 PM »

Try this link for a alphabetical list of FBs keywords:
http://www.freebasic.net/wiki/wikka.php?wakka=AlphaKeywords
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #2 on: June 02, 2005, 04:31:13 PM »

I never saw RTFM written so politely!    :rotfl:

Foolish I, you can do the same things you did in C. Yo can use ALLOCATE, pointer indexing,...
You can do it gfxlib way, creating a big PUT buffer with IMAGECREATE, drawing all your tiles into it and PUT it to screen at differnt coords as your character moves...
Logged

Antoni
Anonymous
Guest
« Reply #3 on: June 02, 2005, 11:36:35 PM »

Code:
 camerax% = char[0].x - (302 \ 2) - 1
  IF camerax% < 0 THEN camerax% = 0
  IF camerax% > ((map[0].room[char[0].currentroom].x) * map[0].tileset.x) - 320 THEN camerax% = ((map[0].room[char[0].currentroom].x) * map[0].tileset.x) - 320

  cameray% = char[0].y - (190 \ 2) - 1
  IF cameray% < 0 THEN cameray% = 0
  IF cameray% > ((map[0].room[char[0].currentroom].y) * map[0].tileset.y) - 200 THEN cameray% = ((map[0].room[char[0].currentroom].y) * map[0].tileset.y) - 200

  xtile% = camerax% \ map[0].tileset.x
  ytile% = cameray% \ map[0].tileset.y

  xoffset% = camerax% Mod map[0].tileset.x
  yoffset% = cameray% Mod map[0].tileset.y



 

  FOR tiley% = 0 TO 208 Step map[0].tileset.y
 
    FOR tilex% = 0 TO 320 Step map[0].tileset.x
      tiletoputx% = tilex% \ map[0].tileset.x + xtile%
      tiletoputy% = (tiley% \ map[0].tileset.y + ytile%) * (map[0].room[char[0].currentroom].x)
      tileindex% = tiletoputy% + tiletoputx%
     
     put (tilex% - xoffset%, tiley% - yoffset%), @map[0].tileset.image[(map[0].room[char[0].currentroom].layout[layertoput%][tileindex%] and 255) * map[0].tileset.arraysize], trans
         
    Next

  Next

   



look at this for a long time, and experiment until it makes a little bit of sense. if it never does, sorry. ill explain this stuff in detail, someday. theres other tuts out there about it. look for em
Logged
Foolish__1
New Member

Posts: 21


« Reply #4 on: June 09, 2005, 04:40:11 PM »

Hey,

Thanks!...  But I still have some questions.  First, what does 'RTFM' mean?  Perhaps I'm a little slow, but?  SEcond, Okay, basically I wast to create a buffer larger than the screen.  Now, I've tried and tried to get this IMAGECREATE command to work, but I just can't.  I've read quite a few tuts on it an dbeen through command references, but It just won't work for me.  Does anyone have a sample of it doing just this?  Thanks again!

-Pauli
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
Anonymous
Guest
« Reply #5 on: June 09, 2005, 05:17:47 PM »

rtfm = read the f___ng manual xD
Logged
Torahteen
Ancient Guru
****
Posts: 744



« Reply #6 on: June 09, 2005, 05:19:22 PM »

:rotfl: Oh! LMAO, now I get it :wink: .
Logged

quote="Deleter"]judging gameplay, you can adaquately compare quake 4 with pong[/quote]
Foolish__1
New Member

Posts: 21


« Reply #7 on: June 18, 2005, 02:43:42 PM »

Hey, it's me, again,

Okay, I've tried to get IMAGECREATE to work, but I can't.  Every example that I can find on the internet start like this:

<?php

Which gives me an error.  If I get rid of that command, none of the other commands work.  Next, I can't do it the way that your example lays out because the tiles have four layers, and are 27*27 at 640*480...  It's just too slow to draw a new row each time.  I have to do it in a similar way to IMAGECREATE.  Sigh.  Does anyone have an example of this actually working, in FB?  Or perhaps a tut on this topic, again for FB, unsing a large buffer like I'm asking...  Because I can't find one...  Please help!!!

Thanks.
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #8 on: June 18, 2005, 03:37:08 PM »

Sorry, Im a bit confused
are you trying to make a tile*tile or pixel*pixel scrolling engine?
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Foolish__1
New Member

Posts: 21


« Reply #9 on: June 19, 2005, 04:37:31 PM »

Well, both.  When your character moves left, he moves one full tile (27 pixels), but it pans one (or two) pixels ata  time, to make a more smooth transition.
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #10 on: June 19, 2005, 06:53:31 PM »

You really dont have to load mapdata on-the-go anymore with FB.
It would be easier and probably work better if you just make one large map array at the start of your program
something like this:

Code:

DIM Map(499, 499) AS INTEGER 'That should be sufficient ^^

'then u can just load into Map(X, Y)
LoadMap bla.map

DO
DrawMap
LOOP

SUB LoadMap (temp.File$)
'appropriate map loading code here which loads
END SUB

SUB DrawMap ()
'approprite tile placement code, just read Map(X, Y)
END SUB
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Foolish__1
New Member

Posts: 21


« Reply #11 on: June 21, 2005, 08:45:58 PM »

Umm, this is what I've tried, and becasue there are four drawn layers, per tile, it ends up being too slow.  When you push, say 'up', it then draws the row of tiles, all four layers, and then moves your character.  It's fine in principal, but in reality it doesn't work.  What happens is if the player hold the up key, the character takes very obvious, jerky steps (after each tile is crossed) and I would like to avoid this as much as possible.  It's a great idea, but in this case just not practical...

I really just need to know how to a make a 'put' array bigger than the screen that I can write directly too.
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
SotSvart
Member
*
Posts: 61



WWW
« Reply #12 on: June 22, 2005, 12:37:26 AM »

You can use IMAGECREATE to make a buffer larger then the screen, and acces it like this: Put Buffer, (x,y), ImgArray(0), PSET

Look up IMAGECREATE and IMAGEDESTROY, in gfxlib.txt. There should also be some examples on how to use a GET/PUT image as a Screen Buffer.
Logged
TheBlueKeyboard
Wandering Guru
***
Posts: 334



« Reply #13 on: June 22, 2005, 12:12:55 PM »

Yes, but are you drawing the entire, say, 500*500 tiles each time, or do you take the little bit of the map that the screen represents and show that?

Assuming the tiles are 16*16:

Code:

SUB DrawMap ()
FOR Layer% = 0 TO 3
StartXTile& = Camera.X \ 16
StartYTile& = Camera.Y \ 16
StartXPixel& = Camera.X MOD 16
StartYPixel& = Camera.Y MOD 16
FOR YTile& = 0 TO 21
FOR XTile& = 0 TO 13
Tile% = Map(XTile& + StartXTile&, YTile& + StartYTile&, Layer%)
PUT (-StartXPixel& + XTile& * 16, -StartYPixel& + YTile& * 16), Tiles(Tile%)
NEXT
NEXT
NEXT
END SUB
Logged

It's the difference between asking someone how much flour goes into pancakes, and handing them a sorry mix of oozing green goo and asking them to fix it." - Deleter

-Founder & President of the No More Religion Threads movement-
Foolish__1
New Member

Posts: 21


« Reply #14 on: June 22, 2005, 02:44:48 PM »

Right now, it only draws the new strip of tiles that need to be.  What happens is the program starts, loads the map into memory, draws the screen.  Then, when you say, move up one tile, it draws that one strip of tiles at the top of the screen, and erases the one at the bottom of the screen.  It's too slow.  The second reason I want to be able to draw buffers larger than the screen is I  am hoping that I can place 'off the screen'...  So that half of the 'put' would be off the screen (hence invisable) and the other half on the screen.  Reason being, is on top of tiles, we want to have larger animation overlayed...  Say a waterfall, or waterwheel...  Perhaps a fire.
The trick is getting this all to work.  It seems it's more difficult than once thought.
Thanks.
Logged

ou're damed if you, well, let's just say your screwed not matter what you do.
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!