Qbasicnews.com

Full Version: Diamond Formula
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Using FOR / NEXT statements, could I create a diamond shape like this?

___H___
__HHH__
_HH=HH_
__HHH__
___H___

Right now I'm using the general square shape For/Next set

for y = 1 to 4
for x = 1 to 4
locate y,x
print $symbol
next x
next y

The empty map is already placed
_______
_______
_______
___=___
_______
_______

I'd like to superimpose a diamond on top of it, centered on the existing = sign.

-------- maybe that's tough to understand.
Ever played Tactics Ogre or FFTactics?
the = is the character, i'm trying to map its movement range

Any suggestions would be helpful
oh... your trying to draw tiles isometrically? i think you need some trig to do that.... first rotate your tiles 45 degrees... then they're supposed to have their perspective changed a bit (from a birds eye to closer to a first person view....) how though, i don't know.
I got it~~~~
dist = ABS(dispX) + ABS(dispY)



No no, not isometrically, I'm working on a flat chessboard.

I've made some progress, just need to get the cursor into account.

My logic right now is that
the ABS(distanceX from center) + ABS(distanceY from center) cannot be greater than the diamond's length.

It would work, but my map scrolls, so I need to make it move with the map.

here's the code i have right now ( messed with it, doesn't take into account the Y values yet)

Code:
FOR dispY = -charaCAP(wChara) TO charaCAP(wChara)
FOR dispX = -charaCAP(wChara) TO charaCAP(wChara)
  tileX = (dispX * 32) - ((cursorX - charaBX(wChara)) * 32) + 144
  tileY = (dispY * 32) - ((cursorY - charaBY(wChara)) * 32) + 84

[b]  dist = ABS(dispX - charaBX(wChara) + cursorX)[/b]
  IF dist <= charaCAP(wChara) THEN displaythetile
NEXT dispX
NEXT dispY

charaCAP = diamond height, right now it is a constant 2
the tile is drawn at coordinates based around the center of the screen

BX is the x position of the character (=) on the map.

cursor is the current focus of the map (the character is not always in the center, but the cursor is)

SEE TOP