Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Zooming in on Part of Screen.

Author
Message
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 18th Oct 2003 16:31
I have been developing a turn based strategy game, basically in 2d, wich devolves to a tactical scren with sprites on moving backgrounds etc.

The one area where I cant seem to get it right is my strategic map. The easiest way for me to go seems to involve using sprites on either a bitmap or sprite background as I can use the sprite collision function to do most of the work for me. The problem however is scrolling around the strategic map.

After some problems I have 3 different ways of scrolling around the map but in each case it means the sprites move with the scroll. I tried offsetting the sprites or moving them but it starts getting messy when there are 30+ sprites on the map, some not moving and the rest being rotated to move in set directions.

I was wondering if there is a set of commands that effectively zooms in on part of the bitmap or background sprite and blows it up, ie, to set a camera point, a field of view and then a display command that then blows that up to full screen. Anything that involves tiling, offsetting backgrounds etc means the sprites move with the scroll and have to be repositioned every turn.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Oct 2003 17:19
There is a way to zoom with bad pixelization if you want it's called...
Scale Bob..Look it up in help.


Things may get pixelized though..... If you don't want pixelization, you are going to have to hand draw a whole new map but much bigger, and hand draw all of your sprites bigger.

Pincho.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 19th Oct 2003 03:01
Thanks for the reply Pincho.

I am using DBPro, upgraded to 5.1.

Could not find "Scale Bob" anywhere in the help manual. Checked every entry in the index under "S" three times. Found things like scale sprite, scale limb etc but not this one.

Sure about the cammand? Could you copy and paste it into your response please?
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Oct 2003 04:20 Edited at: 19th Oct 2003 04:22
Must be scale sprite in DBPro! It's scale Bob in DB Classic. Anyway same thing. Funny but Bob's were Amiga Blitter Objects. They haven't been used by many other computers.

Edit: There's Scale Sprite, and Scale Bob in DB Classic, probably the same thing anyway.

Pincho.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Oct 2003 04:24 Edited at: 19th Oct 2003 04:26
Heres an example with Scale BOB


rem ===================================================
rem DARK BASIC EXAMPLE PROGRAM 5
rem ===================================================
rem This program will draw a scale a bob on screen
rem ---------------------------------------------------

rem Set the ink to white and paper color to black
ink rgb(244,214,210),1

rem Load a bitmap on to the screen
load bitmap "face.bmp"

rem Grab image 1 from bitmap
get image 1,18,17,156,196

rem clear the screen
cls

rem now we will make a bob and draw it off screen
bob 1,100,100,1

rem get bob width and find the middle of it going across
rem get bob height and find the middle of it going down
rem new offset for bob 1

offset bob 1,(bob width(1)/2),(bob height(1)/2)

rem the is were on screen bob will appear
acrossscreen=(640/4)
downscreen=(480/4)

rem press left mouse button to quit
rem move mouse left and right to resize bob

repeat

if returnkey()=1
cls 0
set cursor 0,0
print "using the scale bob command"
print "bob x ",bob x(1)
print "bob y ",bob y(1)
print "bob scale x ",bob scale x(1)
print "bob scale y ",bob scale y(1)
repeat:until returnkey()<>1
cls
endif

rem draw the bob at the new position
bob 1,acrossscreen,downscreen,1

rem resize bob
scale bob 1,mousex()

until mouseclick()=1

rem clear the screen
cls

rem remove the bob from memory
delete bob 1

rem remove image 1 from memory
delete image 1

rem End the program
end
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Oct 2003 04:27
Here's the same with Sprites!


rem ===================================================
rem DARK BASIC EXAMPLE PROGRAM 5
rem ===================================================
rem This program will draw a scale a sprite on screen
rem ---------------------------------------------------

rem Set the ink to white and paper color to black
ink rgb(244,214,210),1

rem Load a bitmap on to the screen
load bitmap "face.bmp"

rem Grab image 1 from bitmap
get image 1,18,17,156,196

rem clear the screen
cls

rem now we will make a sprite and draw it off screen
sprite 1,100,100,1

rem get sprite width and find the middle of it going across
rem get sprite height and find the middle of it going down
rem new offset for sprite 1

offset sprite 1,(sprite width(1)/2),(sprite height(1)/2)

rem the is were on screen sprite will appear
acrossscreen=(640/4)
downscreen=(480/4)

rem press left mouse button to quit
rem move mouse left and right to resize sprite

repeat

if returnkey()=1
cls 0
set cursor 0,0
print "using the scale sprite command"
print "sprite x ",sprite x(1)
print "sprite y ",sprite y(1)
print "sprite scale x ",sprite scale x(1)
print "sprite scale y ",sprite scale y(1)
repeat:until returnkey()<>1
cls
endif

rem draw the sprite at the new position
sprite 1,acrossscreen,downscreen,1

rem resize sprite
scale sprite 1,mousex()

until mouseclick()=1

rem clear the screen
cls

rem remove the sprite from memory
delete sprite 1

rem remove image 1 from memory
delete image 1

rem End the program
end
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 19th Oct 2003 07:04
to advoid the pixelation the pincho mentioned...

In pro sprite images are textures on planes so draw your images very lagre and then use SIZE SPRITE to set them small and SCALE SPRITE to zoom in and not lose quialty.

example
if you want to use 32x32 characters in the game at normal level, draw you images at 160x160, load in the image with LOAD IMAGE create the sprite with SPRITE. now resize the sprite with SIZE SPRITE spritenumber, 32, 32. Now you can zoom 500% with SCALE SPRITE and not get that pixelation.

CTP
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 19th Oct 2003 11:02
Thanks for both the responses

Am trying them now. Did not think of scale sprite although have used it in all the displays. The backdrop (map) works both as a bitmap and a sprite so that might be the way to go.

I am trying them both now.

Thanks again.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 19th Oct 2003 17:44
I am having the same problem with every scrolling technique that I have tried, in fact I have something like 7 working scrolling files with my main bitmap but they all have the same problem.

When I scroll, all the sprites go with the screen because the sprite x,y co-ordinates are set to the visible screen, not to the backdrop. I need to fix the sprites to the backdrop somehow during scrolling. Thats the issue.

I tried writing code to reverse move the sprites during scrolling and it became very messy as I thought it would. To move a sprite it has to be rotated and then moved. It rotates on the point of its x,y location which means they start jumping around. Even if I start offsetting all sprites its going to be a very big code because I will have to set limitations to movement so they dont run off the map if someone keeps pressing the left key once on the left edge and off set and so on and then what to do about sprites that are not actually on the scrolled visible part of the map.

Is there any way of fixing the position of the sprites before I scroll? I have one version where the full backdrop, 2000x1500 is on the visible screen and it works fine but looses a lot of feel because of the small detail. In fact using the sprite collision function would just about do everything I need on this map.

I was hoping to setup everything on the map and then zoom in and move around for a more detailed and entertaining view. One example from the code base I used sets up tiles but my sprite still follows the scroll around. Is it possible to fix the sprites to the tiles during scrolling?

What about the camera functions? Can I set up the large map, place everything then focus on an area say 50% of the x,y co-ordinates of the main map and expand it to 100% (so that the screen displays 25% of the main bitmap?)

Running out of ideas here.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 19th Oct 2003 17:47
PS Many thanks for the helpfull ideas so far.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 19th Oct 2003 18:34
You can easily move the camera to do exactly what you are trying to do. You would use......

set camera to object orientation.....map plain

do

inc xscroll,mousemovex()
inc yscroll,mousemovey()



position camera xscroll,yscroll,0
sync

loop
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 20th Oct 2003 01:57
Hi Pincho,

I have tried many camera commands to date but cant seem to get any to work.

Lets assume I make a sprite 1400 X 1000 as the background then position fixed sprites (ie, bases) on, then starting points of other sprites that can move.

My background sprite would be no 1001,0,0,3(the 3 being the image no).

I want to then focus on the top/left hand quarter. In effect moving the camera view to centre on x350,y250, grab an area 700 X 500 then have that fill the screen without moving the sprites then scroll right or down or back etc as needed, again without moving the sprites.

I have it all working in the larger view, just need to zoom in without disturbing the sprites during the zoom. The sprites x,y co-ordinates to stay as they are on the larger map. Thats the challenge.

Had a quick try with your above suggestion but havnt had time to see if it will work.

Many thanks for your help.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Oct 2003 11:30
Well zooming would be moving the camera in the Z which I haven't put in the example, but you can work that out quite easily.

Pincho.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 20th Oct 2003 17:01
Hi Pincho,

Sorry but I cant get it to work, the camera that is. I tried your commands as well as a large number of combinations of other camera commands with no result.

The code I am using to set up the sprite for the background is attached. It is 1138 X 882.

I then load images and sounds and set sprites in position. During the turn phase I can rotate movable sprites and face them in new directions and then when I press a key to end turn, those sprites move and my turn counter clicks over and prints the new turn on screen. I use the sprite collision function to determine outcomes.

I have not been able to get ANY camera commands to work on this setup or a bitmap only background. Tried things like
make camera 1
set current camera 1
set camera to object orientation 1,1
position camera 1,160,120,0
set camera view 1,0,0,320,240
and many combinations and the ones you suggested with no result.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Oct 2003 21:04
I see the problem with this method is the use of sprites. It's possible to fix the problem, but 3D plains would work much better. Anyway to fix the problem with sprites mean that when you scale all the sprites yourself you are also going to have to move them to their proper positions.

so scale sprite 200 means doubling the X/Y position values of all the sprites on the map.

scale sprite map,200
sprite ship x = sprite ship x*2
sprite ship y = sprite ship y*2

if sprite ship x > screen width then hide sprite ship

etc......

But I'd still go 3D.....

To tell the truth I've only just written a program like this in 3D, and it was something that I have never tried before. It was actually much easier than I thought it was going to be. You can move the camera, and the screen still works like pixels. Van-B helped me with this.......

sync on : sync rate 0

make object plain 1,800,600


Load image "Page 1.bmp",1


texture object 1,1


set camera to object orientation 1

position object 1,-1,0,500


xscroll=camera position x()

do

inc xscroll,mousemovex()


if xscroll<-800 then xscroll=-800
if xscroll>801 then xscroll=801

position camera xscroll,0,0
sync

loop

This uses the mouse to move the screen. You need to change the mousemovex() to your player object x.

Pincho.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 21st Oct 2003 11:10
Thanks Pincho for the help.

According to the Gamemakers support line, camera functions dont work in 2d.

For the time being I will persevere with 2d and try working out how to move the sprites to compensate for the scrolling.

I have a very nice map that I can scroll around, just need to work out the right code to reposition the sprites.

Paste sprite sems to offer promise but I discovered it does not work if the sprites are angled so I have to rotate the sprites back to 0, paste them and the rotate them back again to their original angle.

Thanks again.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 26th Oct 2003 02:32
Mystery partly solved. Help manual needs more detail. Although I did try move sprite with sprite angle and it did not work also.

Reply from gamecreators.
"> Does that mean sprite x,xprite y and sprite angle commands don't work?

Not at all - sprite positions are *not* updated by the PASTE SPRITE command,
and never have been, even in DBC. They are updated by the SPRITE and MOVE
SPRITE commands, and MOVE SPRITE has the bonus of moving the sprite at the
rotated angle - which you might find quite useful "
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 26th Oct 2003 03:56
very simalar to my reply to CodeOrc only a week ago, http://www.thegamecreators.com/?m=forum_view&t=18656&b=4
Quote: "also your using PASTE SPRITE to display the sprite, but calling MIRROR SPRITE will flip the sprite , which is located with SPRITE command. SPRITE COLLISION also only works with the real sprite location, 'where the sprite is set with the SPRITE command, not the PASTE SPRITE which does nothing more then draw the image that the sprite is currently using NOT the SPRITE sprite location can only be changed with the SPRITE command or MOVE SPRITE command"

There's a wealth of info on this forum if people only take the time to look.

Glad you got it worked out.

CTP

Login to post a reply

Server time is: 2024-04-28 06:59:18
Your offset time is: 2024-04-28 06:59:18