Posts: 306
Threads: 14
Joined: Nov 2002
lol Those sprites are awesome.. would love to play a game like lemmings with nothing but those guys in it.
Posts: 3,288
Threads: 167
Joined: Nov 2001
Don't worry, the grafix of DW3 would have that as the main character. ;*)
Posts: 1,813
Threads: 284
Joined: Mar 2003
Code: ' B. Man
' by Seph
' commented specifically and ONLY for Agamemnus
' if you read the comments and aren't him, I'm suing!
DECLARE SUB DrawSolidBricks (brick() AS INTEGER)
DECLARE SUB DrawBricks (brick() AS INTEGER)
DECLARE SUB BombCheck (bomb() AS INTEGER)
'$INCLUDE: 'dqb2\directqb.bi'
' Directions. Important that right and left are inversed signs, since the SEGMENTs and OFFSETs use the ABS() of them.
' 0, 1, and 2 is the order they appear in the file, which is also important.
CONST MANRIGHT = -1, MANDOWN = 0, MANLEFT = 1, MANUP = 2
' Layers I need. The order the numbers are in do not matter.
CONST layerWalls = 1, layerItems = 2, layerBombs = 3, layerCombo = 4, layerBOOM = 5, layerBackground = 6
RANDOMIZE TIMER
CLS
TYPE playertype
x AS INTEGER ' actual x
y AS INTEGER ' actual y
xint AS INTEGER ' x of the guy's tile coordinates
yint AS INTEGER ' y of the guy's tile coordinates
dir AS INTEGER ' direction he's facing
walking AS INTEGER ' walking or not
addseg AS INTEGER ' segment add. of his image
addoff AS INTEGER ' offset add. of his image
addsegstill AS INTEGER ' segment add. of his image standing still (to ensure he doesnt walk into walls and get stuck)
addoffstill AS INTEGER ' offset add. of his image standing still (to ensure he doesnt walk into walls and get stuck)
bombsize AS INTEGER ' in the future, this will be for the number of tiles his bombs go in each direction. starts off at 0
END TYPE
TYPE bombtype
x AS INTEGER ' actual x
y AS INTEGER ' actual y
timeup AS SINGLE ' when TIMER is past this, blow up the goddamn thing
size AS INTEGER ' passed on from player.bombsize
END TYPE
TYPE explotype
x AS INTEGER ' actual x
y AS INTEGER ' actual y
size AS INTEGER ' passed on from player.bombsize
END TYPE
TYPE itemtype
x AS INTEGER ' actual x
y AS INTEGER ' actual y
addseg AS INTEGER ' segment add. of each individual item's image
addoff AS INTEGER ' offset add. of each individual item's image
END TYPE
TYPE bricktype
x AS INTEGER ' actual x
y AS INTEGER ' actual y
addseg AS INTEGER ' segment add. of the brick's image
addoff AS INTEGER ' offset add. of the brick's image
END TYPE
' Start DQB with 6 layers. I don't know if 384 applies, since it's just a change from my previous version of DQB (1.5 i think)
IF DQBinit(6, 0, 384) THEN DQBclose: PRINT DQBerror$: END
' Start keyboard
DQBinstallKeyboard
' SCREEN 13
DQBinitVGA
' collide by pixels, not boxes. doesnt seem to work, but fuhck it.
DQBsetCollideMethod 1
' This is the main guy for his values
DIM man AS playertype
' This is the items array for all items when they will be coded
DIM items(255) AS itemtype
' This is the bombs array for ALL bombs
DIM bombs(255) AS bombtype
' To keep track of the number of items available so we don't run out of items after 256.
DIM numitems%
' To keep track of the number of bombs available so we don't run out of bombs after 256.
DIM numbombs%
' Just speed.
DIM SHARED speed%
' Adjustment of the entire map, since I can't fit it on the whole damn screen.
DIM SHARED adjX%, adjY%
numitems% = 0
numbombs% = 0
speed% = 1
adjX% = 24
adjY% = 12
' These are arrays for the images
DIM player(2322) AS INTEGER
DIM solidbrick(258) AS INTEGER
DIM brick(258) AS INTEGER
DIM bomb(516) AS INTEGER
' Setting up the background. It can get fancy layer :)
DQBpaint layerBackground, 0, 0, 222
DQBboxF layerBackground, 16 + adjX%, 16 + adjY%, (16 * 16) + adjX%, (16 * 10) + adjY%, 125
' Loading the images into the arrays
DEF SEG = VARSEG(player(0))
BLOAD "images/bomber.put", VARPTR(player(0))
DEF SEG = VARSEG(solidbrick(0))
BLOAD "images/solid.put", VARPTR(solidbrick(0))
DEF SEG = VARSEG(brick(0))
BLOAD "images/brick.put", VARPTR(solidbrick(0))
DEF SEG = VARSEG(bomb(0))
BLOAD "images/bomb.put", VARPTR(bomb(0))
DEF SEG
' Read the damn SUBs' names!
DrawSolidBricks solidbrick()
DrawBricks brick()
' Setting up your guy at first.
man.dir = MANDOWN
man.x = 16 + adjX%
man.y = 16 + adjY%
man.xint = ((man.x - adjX%) + 8) \ 16
man.yint = ((man.y - adjY%) + 8) \ 16
man.addseg = VARSEG(player(130 * (ABS(man.dir) * 3 + walkingstate%)))
man.addoff = VARPTR(player(130 * (ABS(man.dir) * 3 + walkingstate%)))
' Set up the timer variable for walking sprites. Mmmm, Sprite.
t! = TIMER
DO
' Do I even need this damn thing anymore?
WAIT &H3DA, 8
' Just a little thingy I added for my gf, to show her you can move the whole screen.
' I might use this for shaking the screen for huge bombs or bosses, or fat characters walking.
IF resetbg% = 1 THEN
resetbg% = 0
DQBclearLayer layerBackground
DQBpaint layerBackground, 0, 0, 222
DQBboxF layerBackground, 16 + adjX%, 16 + adjY%, (16 * 16) + adjX%, (16 * 10) + adjY%, 125
DQBclearLayer layerWalls
DQBclearLayer layerItems
DQBclearLayer layerBombs
DrawSolidBricks solidbrick()
DrawBricks brick()
END IF
DQBcopyLayer layerBackground, layerCombo ' Print background onto layer
DQBcopyTransLayer layerWalls, layerCombo ' Print solid walls onto layer
DQBcopyTransLayer layerItems, layerCombo ' Print breakable walls and items onto layer
DQBcopyTransLayer layerBombs, layerCombo ' Print bombs onto layer
'DQBcopyTransLayer layerBOOM, layerCombo ' Soon to print explosion animation onto layer
man.walking = 0 ' He ain't movin.
IF DQBkey(1) THEN EXIT DO ' He wants to Escape. Let him!
IF DQBkey(75) THEN
hitwall% = DQBcollideOnLayer(layerWalls, man.x - speed%, man.y, man.addsegstill, man.addoffstill) <> 0
hititem% = DQBcollideOnLayer(layerItems, man.x - speed%, man.y, man.addsegstill, man.addoffstill) <> 0
' Check if he's hitting a wall or an item.
' If he didn't, move him.
IF hitwall% = 0 AND hititem% = 0 THEN
man.x = man.x - speed%
man.dir = MANLEFT
man.walking = 1
man.xint = ((man.x - adjX%) + 8) \ 16
END IF
END IF
IF DQBkey(77) THEN
hitwall% = DQBcollideOnLayer(layerWalls, man.x + speed%, man.y, man.addsegstill, man.addoffstill)
hititem% = DQBcollideOnLayer(layerItems, man.x + speed%, man.y, man.addsegstill, man.addoffstill)
' See: DQBkey(75)
IF hitwall% = 0 AND hititem% = 0 THEN
man.x = man.x + speed%
man.dir = MANRIGHT
man.walking = 1
man.xint = ((man.x - adjX%) + 8) \ 16
END IF
END IF
IF DQBkey(72) THEN
hitwall% = DQBcollideOnLayer(layerWalls, man.x, man.y - speed%, man.addsegstill, man.addoffstill)
hititem% = DQBcollideOnLayer(layerItems, man.x, man.y - speed%, man.addsegstill, man.addoffstill)
' See: DQBkey(75)
IF hitwall% = 0 AND hititem% = 0 THEN
man.y = man.y - speed%
man.dir = MANUP
man.walking = 1
man.yint = ((man.y - adjY%) + 8) \ 16
END IF
END IF
IF DQBkey(80) THEN
hitwall% = DQBcollideOnLayer(layerWalls, man.x, man.y + speed%, man.addsegstill, man.addoffstill)
hititem% = DQBcollideOnLayer(layerItems, man.x, man.y + speed%, man.addsegstill, man.addoffstill)
' See: DQBkey(75)
IF hitwall% = 0 AND hititem% = 0 THEN
man.y = man.y + speed%
man.dir = MANDOWN
man.walking = 1
man.yint = ((man.y - adjY%) + 8) \ 16
END IF
END IF
' Again, for the screen shaking idea...
IF DQBkey(2) THEN adjX% = adjX% + 1: resetbg% = 1
IF DQBkey(3) THEN adjX% = adjX% - 1: resetbg% = 1
IF DQBkey(4) THEN adjY% = adjY% + 1: resetbg% = 1
IF DQBkey(5) THEN adjY% = adjY% - 1: resetbg% = 1
IF DQBkey(57) THEN
' If he's pressing Spacebar, he wants to set a bomb.
setbomb% = 1
ELSEIF setbomb% = 1 THEN
' If he let go, then set the damn bomb. Otherwise you create craploads of bombs at once.
setbomb% = 0
numbombs% = numbombs% + 1
bombs(numbombs%).x = (16 * man.xint) + adjX%
bombs(numbombs%).y = (16 * man.yint) + adjY%
bombs(numbombs%).timeup = TIMER + 3.5
END IF
' Checking each bomb in the array to see if it's throbbing or exploding yet.
FOR i = 1 TO numbombs%
' Majour Throb Action!
IF TIMER - bombtime! >= .3 THEN
bombstate% = NOT bombstate%
bombtime! = TIMER
END IF
' Erase the bomb so it can throb properly.
DQBboxF layerBombs, bombs(i).x, bombs(i).y, bombs(i).x + 15, bombs(i).y + 15, 0
' If it's exploding, erase the bomb from the array.
IF TIMER >= bombs(i).timeup THEN
numbombs% = numbombs% - 1
' Move all the bombs above this one down by one.
' Otherwise, once you get to bombs(255), you're screwed.
FOR i2 = i TO numbombs%
bombs(i2).x = bombs(i2 + 1).x
bombs(i2).y = bombs(i2 + 1).y
bombs(i2).timeup = bombs(i2 + 1).timeup
NEXT i2
ELSE
' Draw the fuhcker.
DQBput layerBombs, bombs(i).x, bombs(i).y, VARSEG(bomb(130 * ABS(bombstate%))), VARPTR(bomb(130 * ABS(bombstate%)))
END IF
NEXT i
' Let him walk.
IF man.walking = 1 THEN
IF TIMER - t! >= .25 / speed% THEN
IF walkingstate% = 1 THEN
walkingstate% = 2
ELSE
walkingstate% = 1
END IF
t! = TIMER
END IF
ELSE
walkingstate% = 0
END IF
' Update the guy's stats so we can use them elsewhere.
man.addseg = VARSEG(player(130 * (ABS(man.dir) * 3 + walkingstate%)))
man.addoff = VARPTR(player(130 * (ABS(man.dir) * 3 + walkingstate%)))
man.addsegstill = VARSEG(player(130 * (ABS(man.dir) * 3)))
man.addoffstill = VARPTR(player(130 * (ABS(man.dir) * 3)))
' Seriously, do I? I mean, I use layers now.
' On second thought, if I don't, the program runs too damn fast.
WAIT &H3DA, 8, 8
' Draw the guy in the proper direction. Or ELSE!!!!
DQBmPut layerCombo, man.x, man.y, man.addseg, man.addoff, ABS(man.dir = MANRIGHT)
' You know how we drew everything and you can't see it yet? Well this is where we let you.
DQBcopyLayer layerCombo, VIDEO
LOOP
' Let go of the keyboard and DQB itself. Cuz if you don't, you're fuhcked.
DQBremoveKeyboard
DQBclose
REM $DYNAMIC
SUB DrawBricks (brick() AS INTEGER)
FOR y = 2 TO 8
FOR x = 2 TO 14
doit = INT(RND * 8)
IF y AND 1 THEN
IF doit THEN DQBput layerItems, x * 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
ELSEIF x AND 1 THEN
IF doit THEN DQBput layerItems, x * 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
END IF
NEXT x
NEXT y
FOR y = 3 TO 7
doit = INT(RND * 8)
IF doit THEN DQBput layerItems, 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
IF doit THEN DQBput layerItems, 15 * 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
NEXT y
FOR x = 3 TO 13
doit = INT(RND * 8)
IF doit THEN DQBput layerItems, x * 16 + adjX%, (1 * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
IF doit THEN DQBput layerItems, x * 16 + adjX%, (9 * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
NEXT x
END SUB
SUB DrawSolidBricks (brick() AS INTEGER)
FOR i = 0 TO 10
DQBput layerWalls, 256 + adjX%, (i * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
DQBput layerWalls, 0 + adjX%, (i * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
NEXT i
FOR i = 1 TO 15
DQBput layerWalls, i * 16 + adjX%, adjY%, VARSEG(brick(0)), VARPTR(brick(0))
DQBput layerWalls, i * 16 + adjX%, 160 + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
NEXT i
FOR y = 2 TO 8 STEP 2
FOR x = 2 TO 15 STEP 2
DQBput layerWalls, x * 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
DQBput layerWalls, x * 16 + adjX%, (y * 16) + adjY%, VARSEG(brick(0)), VARPTR(brick(0))
NEXT x
NEXT y
END SUB
earn.
Posts: 1,845
Threads: 44
Joined: Aug 2002
oops, I read the comments
Posts: 1,439
Threads: 15
Joined: Apr 2003
Do we get sued if we just read the code?
Posts: 1,813
Threads: 284
Joined: Mar 2003
|