Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tank war
#21
Quote:Do not use american algorithms, they usually miss and hit town markets.
Hehe... oh, wait... I'm from the US... as long as they don't hit my town market... :-?
Reply
#22
Ah, Scorched Earth...
I remember the days of playing hours of it in a musty basement on an old 386 with my brother.

*Falls into dreamy state*
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Reply
#23
Quote:Since you are all making up formula, this is the one I'm talking about.
Code:
d = ((px - ex - 10) ^ 2 + (py - ey - 5) ^ 2) ^ .5
xs = -1 / d ^ 2 * 30000 * (px - ex - 10) / d
ys = -1 / d ^ 2 * 30000 * (py - ey - 5) / d

I modified it recently... I'll try to find the new one somewhere, and I'll post the game if I ever find it.

Hehehe. Mines faster. ;*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#24
I'd look at it if I had RelLib. Do you want me to host it on QBNZ?
Reply
#25
Quote:I'd look at it if I had RelLib. Do you want me to host it on QBNZ?

No Problem. But RelAngle uses ATN that's why it does return and angle from 0 to 359.

Whereas this uses a modified Dot Product.

ie, D!=(ax*bx)+(ay*by)

Code:
'/An example of doing homing missiles w/o using ATN
'/Obscure but very fast considering it only uses multiplication
'/Code by Relsoft, SetVideoSeg by Plasma357

DECLARE SUB DoHoming (P AS ANY)
DECLARE SUB SetVideoSeg (Segment%)
DEFINT A-Z


TYPE PointType
        X               AS INTEGER
        Y               AS INTEGER
        XV              AS INTEGER
        YV              AS INTEGER
        Speed           AS INTEGER
        TX              AS INTEGER
        TY              AS INTEGER
        Dot             AS INTEGER
        Angle           AS INTEGER
        AngleStep       AS INTEGER
        NewTarget       AS INTEGER
        Animate         AS INTEGER
        C               AS INTEGER
END TYPE

CONST FALSE = 0, TRUE = NOT FALSE
CONST PI = 3.14151693#
CONST Fixpoint = 256
CONST MaxVector = 10             'Change this to how many points you want


REDIM SHARED Vpage(32009)  AS INTEGER

DIM SHARED LCos(359) AS INTEGER
DIM SHARED LSin(359) AS INTEGER
DIM SHARED Vector(MaxVector) AS PointType


'PreCalc sin and cos lookuptable

FOR I = 0 TO 359
    A! = (I * PI / 180)
    LCos(I) = COS(A!) * Fixpoint
    LSin(I) = SIN(A!) * Fixpoint
NEXT I

'Init Vectors,etc
FOR I = 0 TO UBOUND(Vector)
        Vector(I).X = INT(RND * 320)
        Vector(I).Y = INT(RND * 200)
        Vector(I).Angle = 0
        Vector(I).AngleStep = 8
        Vector(I).Speed = 3
        Vector(I).C = 1 + INT(RND * 16)
NEXT I


CLS
SCREEN 13
RANDOMIZE TIMER

Vpage(6) = 2560
Vpage(7) = 200
Layer = VARSEG(Vpage(0)) + 1
SetVideoSeg Layer

DO
    FOR I = 0 TO UBOUND(Vector)
            DoHoming Vector(I)
    NEXT I
    SetVideoSeg Layer
    LINE (0, 0)-(319, 199), 0, BF
    FOR I = 0 TO UBOUND(Vector)
            X = Vector(I).X
            Y = Vector(I).Y
            C = Vector(I).C
            XX = LCos(Vector(I).Angle) / Fixpoint * 5
            YY = LSin(Vector(I).Angle) / Fixpoint * 5
            CIRCLE (X, Y), 2, C
            LINE (X, Y)-(X + XX, Y + YY), C

            TX = Vector(I).TX
            TY = Vector(I).TY
            C = Vector(I).C
            PSET (TX, TY), C

    NEXT I
    SetVideoSeg &HA000
    WAIT &H3DA, 8
    PUT (0, 0), Vpage(6), PSET
LOOP UNTIL INKEY$ <> ""

SUB DoHoming (P AS PointType) STATIC

        IF P.NewTarget THEN
                P.TX = INT(RND * 320)
                P.TY = INT(RND * 200)
                P.NewTarget = FALSE
        END IF

        'move the missile
        P.XV = (LCos(P.Angle) / Fixpoint) * P.Speed
        P.YV = (LSin(P.Angle) / Fixpoint) * P.Speed

        P.X = P.X + P.XV
        P.Y = P.Y + P.YV

        IF ABS(P.TX - P.X) AND ABS(P.TY - P.Y) < 5 THEN
                P.NewTarget = TRUE
        END IF

        'Check if Result>0 then Dec else Inc
        'the actual angle is not important
        P.Dot = ((P.YV * (P.TX - P.X)) - (P.XV * (P.TY - P.Y)))
        IF P.Dot > 0 THEN
                P.Angle = (P.Angle - P.AngleStep)
                IF P.Angle < 0 THEN P.Angle = P.Angle + 360
        ELSE
                P.Angle = (P.Angle + P.AngleStep) MOD 360
        END IF


END SUB

SUB SetVideoSeg (Segment) STATIC

DEF SEG

IF VideoAddrOff& = 0 THEN ' First time the sub is called

' We need to find the location of b$AddrC, which holds the graphics
' offset (b$OffC) and segment (b$SegC). Since b$AddrC is in the default
' segment, we can find it by setting it to a certain value, and then
' searching for that value.

SCREEN 13 ' Set b$SegC to A000 (00A0 in memory)
PSET (160, 100), 0 ' Set b$OffC to 7DA0 (not needed in the IDE)

FOR Offset& = 0 TO 32764 ' Search for b$AddrC, which is
IF PEEK(Offset&) = &HA0 THEN ' in the default segment and
IF PEEK(Offset& + 1) = &H7D THEN ' should have a value of
IF PEEK(Offset& + 2) = &H0 THEN ' A0 7D 00 A0.
IF PEEK(Offset& + 3) = &HA0 THEN
VideoAddrOff& = Offset& + 2 ' If we found it, record the
EXIT FOR ' offset of b$SegC and quit
END IF ' looking. (Oddly, changing
END IF ' the b$OffC doesn't seem to
END IF ' do anything, so this is why
END IF ' this sub only changes b$SegC)
NEXT

END IF

' Change b$SegC to the specified Segment

POKE VideoAddrOff&, Segment AND &HFF
POKE VideoAddrOff& + 1, (Segment AND &HFF00&) \ &H100



END SUB
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#26
Hmmmm... Could you alter it to have the dot moving? Can you alter the amount that the missile homes in by (I'm talking worms armageddon style here, your homers in that prog are *way* to accurate :wink: )

Other random thought: could anyone make a "cruise missile"? One that hugs some randomly generated terrain?
Reply
#27
Yeah, The dot is supposed to move. But this is not an exercise of my coding skills, just to show the algo.

Yeah a cruise missile is no that impossible. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#28
Wow this page is so long that I gave up reading it half way through. I just want to say this:

Back when I had a really old computer and the best thing we could run on it was MegaMan X (it was cool cause it had an 8x CD ROM drive in it) Scorched Earth was one of my favorites.

SHAME ON ANY OF YOU WHO HAVE NOT PLAYED IT!!!

hehe, just kidding. BTW: Scorched Earth C A N be a little funny... you can go into some of the files and change what the computers say when they attack, die, kill something... etc.... yeah. Otherwise it is the 'mother of all games' just like it says it is.

(THIS HAS NO IMPORTANCE TO THE PAGE BUT I THOUGHT YOU ALL WOULD LIKE TO KNOW MY FEELINGS) :normal:
ovaProgramming.

One night I had a dream where I was breaking balls. The next morning, BALLSBREAKER was born.

Quote: Excellent. Now you can have things without paying for them.

BALLSBREAKER 2
~-_-Status Report-_-~
Engine: 94%
Graphics: 95%
Sound: 100%
A Severe Error has crippled BB2 for the time being... I have to figure it out, but until then you won't see much of it Sad.
-----------------------------
Reply
#29
You guys should check out Linux's XScorch then. It's awesome. You can use as weapons Missiles, MIRVs, Nuclear warheads and Napalm, not to mention all the defense you can get, whats more you can move!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)