Jump to content
IGNORED

Big Guns !


Retrospect

Recommended Posts

GUNS.zip

 

post-34058-0-36474500-1351061922_thumb.png

 

Works with standard TI console with Extended Basic

 

Two players.

 

First, enter your lift factor (between 10 and 100)

Then, enter your powder factor (between 10 and 100)

 

Wind is variable (even though my clouds move one way ?! ) so you won't get the same

shot twice.

 

Most of all, HAVE FUN!

:D

 

(note: if using powder of 90 or above, in some cases this causes the cannon-ball to wrap around the screen. This is a minor issue that will be resolved later, it does not detract from the game)

Edited by Retrospect
  • Like 1
Link to comment
Share on other sites

That looks like fun :)

 

If given time, I will probably expand my game to do something tricky ....

 

In the meantime, I have cooked up a single-player version of Big Guns .... because not all of us can get our wives or friends to sit and play.

 

This one lets the computer take over as player two.

 

ONEPLAYER.zip

Link to comment
Share on other sites

1. Initially

Wow, where do they come from ?

 

2. First impression

Looks absolutely cool. Good design, layout and graphics.

 

3. The game

Interface on average or better (for the TI) for that type of game. Projectile moves a bit unexpectedly. Quickly lost interest. Would have loved to see what a hit looks like.

 

4. Overall / feedback

One player is a very nice addition. Fix the path of projectiles to be somewhat more realistic, and TI would easily have sold them on cassette for USD 9.99. Great work. Very inspirational. Not to compete, but now I really have to do something (cook up a nice little game).

 

:)

  • Like 2
Link to comment
Share on other sites

1. Initially

Wow, where do they come from ?

 

2. First impression

Looks absolutely cool. Good design, layout and graphics.

 

3. The game

Interface on average or better (for the TI) for that type of game. Projectile moves a bit unexpectedly. Quickly lost interest. Would have loved to see what a hit looks like.

 

4. Overall / feedback

One player is a very nice addition. Fix the path of projectiles to be somewhat more realistic, and TI would easily have sold them on cassette for USD 9.99. Great work. Very inspirational. Not to compete, but now I really have to do something (cook up a nice little game).

 

:)

 

Thankyou for the fantastic feedback :)

 

Now we mention the projectiles, i will admit I am totally lost in how to do it. I used a completely happy-go-lucky routine and did a bad randomiser to calculate wind (i had to have wind, otherwise you would know the exact numbers to get a hit every time.)

 

I really need to know, if there is a COSine command or something that will help my routine, i have been trying this morning but no good .... again though, karsten thanks for the feedback.

 

Also, yes! you absolutely must do a game i would love to see it ..... ive seen your work on graphics and to be honest, brilliant ..... get a game out man! :)

Edited by Retrospect
Link to comment
Share on other sites

Wow! RESPECT Retrospect! You're really cranking these out!

 

I should take one and convert it to Forth so you can see how it's done!

 

Mark

 

Please do, I would like to see the forth source and how it performs/executes :)

 

This game was started on at 3.30am and finished finally at around 8.00am, with only one or two bugs in it.

 

The main thing is the projectiles are erratic, I tried to get around this by saying it's because of the random wind-facter (there indeed is one) ... but no amount of wind would make the cannon balls do what they do.

 

I need to know a routine where the bloody things will swoop in accordance to user input on lift and powder amount, and the added element of wind .... <<<head thrash>>>

Edited by Retrospect
Link to comment
Share on other sites

...

I really need to know, if there is a COSine command or something that will help my routine, i have been trying this morning but no good ....

 

There is, indeed, a cosine function (COS), as well as a sine (SIN), tangent (TAN) and arctangent (inverse tangent = ATN); but, they may well slow you down. The argument for each of COS, SIN and TAN is in radians. If you have degrees, convert by multiplying by PI/180. ATN will convert tangent to radians. Integer versions of these functions would no doubt be better and some folks on this forum probably have such beasties.

 

...lee

  • Like 1
Link to comment
Share on other sites

Thanks Lee. I am experimenting with SINe at the moment, just playing with a few numbers.

hehe .... It's all fun isn't it ....

 

SO ... instead of using CALL MOTION, I am going to find the right routine with SINe, COSine or whatever ... and have those physically place the sprite pixel by pixel. I don't really know what I'm doing, but that's normal.

Link to comment
Share on other sites

Try this one out. :)

 

100 CALL SPRITE(#1,46,2,180,16)::CALL CLEAR
110 Y=180:=16::YDELTA=-6-RND*12::GRAVITY=1::XDELTA=3+RND*3
120 Y=Y+YDELTA::YDELTA=YDELTA+GRAVITY:=X+XDELTA
130 CALL LOCATE(#1,Y,X)::IF Y<180 THEN 120 ELSE 110

 

Trigonometric functions are nice when you want to find a position at any given time, but with animation/movement you can sometimes calculate the next position in time with things like speed and acceleration, in this case called delta (both directions) and gravity (only in the y direction).

Edited by sometimes99er
  • Like 2
Link to comment
Share on other sites

Thankyou Retroclouds :)

 

I'll keep plugging away at it until I get it right, I have kindly been given some code that should help with the cannon balls, I just have to figure out how to implement my lift/powder variables into them.

 

I have another game planned, but it's being shelved for now .... it's going to be good, though.

  • Like 1
Link to comment
Share on other sites

To get you going, take a look at this.

 

sinus.jpg

 

"v" is your lift (or I assume it is). "1" is just one and projecting on the x and y axis as cos(v) and sin(v). If "1" is not one, let's say "p" for power, then it becomes p*cos(v) and p*sin(v). Or xdelta = p*cos(v) and ydelta = p*sin(v). This is true but the input and output have to be massaged (simple multiply or divide) to fit your chosen ranges and the screen dimensions (which I did in the demo (using a few trial and errors)).

 

This is only for the setup. The actual animation/movement will be as in the demo with no use of cos and sin - which by the way (the use of cos) may be as fast and/or efficient. The method of not using cos, but speed and acceleration is common ground in Flash games, where for example certain surfaces can have different deaccelerations, gravity with different strength over distance (navigating between planets) etc. It's not because cos is something to avoid, just makes a lot of sense to use speed and acceleration - at least for a projectile.

 

Also when it comes to Assembly, straight arithmetic is easy. When calculating the distance between two objects (Pythagoras), you don't have to take the square root, just as long as you know the results are exponential - who cares about the right distance if anything less than, say 16, is considered a hit/collision between objects.

Edited by sometimes99er
Link to comment
Share on other sites

Here is something I did a while ago. Just tweaked a few things to make it respond a little better.

 

The guts are subroutines at 1000 and 2000, the animation loop at 300 shows how to use them. The variables are:

 

TICK - How fast the projectile will animate. I used to have this at a fixed value, but for low angles it was too slow, and for steep angles it was too fast. So, in line 310 the TICK is adjusted based on the angle, which gives a consistent animation speed to the projectile.

 

DEG2RAD - Used to convert degrees to radians for the SIN and COS.

 

G - Gravity constant in meters.

 

SPEED - The initial velocity or power being applied to the projectile. You would get this value from the player.

 

ANGLE - Angle of the projectile, also collected from the player.

 

X,Y - The starting location of the projectile in pixels.

 

T - Time. This is what changes to animate the projectile. The change per animation tick is determined by TICK (see above). You always want to start time at 0, unless you want to get the location of the projectile at a certain point in time.

 

XV,YV - Calculated X,Y velocity based on the input SPEED and ANGLE. These only need to be calculated once when the SPEED or ANGLE changes. The only variable that needs to be changed to animate the projectile is time (T).

 

XD,YD - X,Y Delta (change). The main result of the subroutine at 2000. Add XD to your sprite's X, and subtract YD from your sprite's Y. You subtract YD because the screen coordinate 0,0 is the top left instead of the bottom left as it would be in mathematics.

 

100- Init the screen and variables

 

200- Get and validate user input

 

300- Init time (T) to 0, calculate the animation TICK

320- One time per animation initialization

330- Start of loop to calculate X,Y deltas

340- Range check deltas based on screen limits

350- Update projectile sprite

360- Loop to update X,Y deltas

 

400- Show a "splat" where the projectile would have hit or gone off screen

410- Back up two time periods to bring the projectile to where it was prior to going out of bounds

420- Calculate the deltas based on the backed-up time

430- Display splat sprite

440- Go back to get user input

 

This program stops the calculations when the projectile goes out of bounds, even if it might have returned to the screen at a later time, i.e. with a steep angle and high power. You can compensate for that if you want, but I'll leave that up to you.

 

100 TICK=3.0::DEG2RAD=PI/180::G=9.81
110 GOSUB 3000::GOSUB 4000
120 X=5::Y=179::SPEED=10::ANGLE=45::T=0

200 REM GET SPEED AND ANGLE
210 CALL SPRITE(#1,46,2,Y,X)
220 DISPLAY AT(22,2):"POWER: "::ACCEPT AT(22,9)VALIDATE(NUMERIC):SPEED
230 IF SPEED<G OR SPEED>99 THEN 220
240 DISPLAY AT(23,2):"ANGLE: "::ACCEPT AT(23,9)VALIDATE(NUMERIC):ANGLE
250 IF ANGLE<1 OR ANGLE>=90 THEN 240
260 GOSUB 4000
260 GOSUB 4000

300 REM ANIMATION LOOP
310 T=0::TICK=COS(ANGLE*DEG2RAD)*10
320 GOSUB 1000
330 GOSUB 2000
340 IF DONE=1 OR (X+XD)>248 OR (Y-YD)<1 THEN 400
350 CALL LOCATE(#1,Y-YD,X+XD)
360 GOTO 330

400 REM SPLAT
410 T=T-(TDELTA*2)
420 GOSUB 2000
430 CALL SPRITE(#2,64,2,Y-YD,X+XD)
440 GOTO 200

1000 REM INIT TRAJECTORY
1010 RAD=ANGLE*DEG2RAD
1020 XV=SPEED*COS(RAD)
1030 YV=SPEED*SIN(RAD)
1040 TDELTA=TICK/XV
1050 RETURN

2000 REM CALC TRAJECTORY STEP
2010 XD=XV*T
2020 YD=YV*T-(G*T*T)*0.5
2030 IF XD>=0 AND YD>=0.0 THEN DONE=0 ELSE DONE=1
2040 T=T+TDELTA
2050 RETURN

3000 REM INIT SCREEN
3010 CALL CLEAR::CALL SCREEN(5)::CALL COLOR(1,6,1,2,16,1)
3020 CALL CHAR(32,"000004000000000040E04")
3030 CALL CHAR(40,"040E1F0404040C0404041C0404040C0404041F0404")
3040 CALL CHAR(43,"0000FF44040000000406FF4604")
3050 RETURN

4000 REM DISPLAY COORDINATE SYSTEM
4010 CALL CLEAR
4020 CALL HCHAR(1,1,40)::CALL VCHAR(2,1,41,22)::CALL HCHAR(24,1,42)
4030 CALL HCHAR(24,2,43,30)::CALL HCHAR(24,32,44)
4040 RETURN

  • Like 1
Link to comment
Share on other sites

Thankyou Matthew for the code.

 

I've kept the graphics, just moved the graphics code to lines starting from 9000 with a gosub from line 100 to get them on screen, the rest of my code has been scrapped as it was no good. Your code , and karsten's code, will be used for the projectiles left and right.

 

A reworked interface for input will be used, I'm thinking of use of arrow keys for lift up and down, and numeric input for powder.

 

I'll be back with a reworked Big Guns as soon as possible :)

Link to comment
Share on other sites

La Résistance

 

Just a quick mod ...

 

80 CALL CLEAR::CALL SCREEN(2)
90 CALL CHAR(33,"74BC74",34,"70F87F")
92 FOR X=2 TO 6::CALL SPRITE(#X,33,7+X,X*26,RND*254+1,0,-5)::NEXT X
94 FOR X=7 TO 9::CALL SPRITE(#X,34,16,X*5-20,RND*254+1,0,SGN(RND-.5))::NEXT X
100 CALL SPRITE(#1,111,16,180,16)
105 CALL COLOR(1,5,5,2,8,::CALL HCHAR(1,1,40,128)
110 Y=180:=16::YD=-10-RND*16::GR=1::WATER=.9::XD=10+RND*10
120 Y=Y+YD::YD=(YD+GR)*WATER:=X+XD::XD=XD*WATER
130 CALL LOCATE(#1,Y,X)::IF Y<180 THEN 120 ELSE 110

 

;)

  • Like 2
Link to comment
Share on other sites

If you want to better understand the math behind all this, check out a few trajectory tutorial. What I found interesting (and never really thought about until I messed with the math) about trajectory is that the X and Y velocity don't affect one another. X is a function of time and X velocity, while Y is a function of time, Y velocity, and gravity.

 

The addition of the cosine and sine stuff above are just to get the proper amount of X and Y velocity based on an angle and some amount of initial velocity (or power if you want to call it that).

 

If you look at X alone, and think about just dropping a ball from above, it would be:

 

X=VX*T

 

If VX (velocity X) is 0, then X is always 0, which makes since because you just dropped the ball. Also note that the formula does not take in to consideration any kind of resistance (like air for example) for X. An object in motion stays in motion. You could add friction I suppose, or modify VX based on a wind-speed.

 

Since free falling acceleration, on Earth, is approximately 9.8 m/s/s (meters per second per second), then you would get something like this:

 

Time | Velocity(m/s)
 0      0
 1      9.8
 2      19.6
 3      29.4
 4      39.2
 5      49.0

 

So after 5 seconds you are moving at 49 meters per second! Based on that, the formula to derive distance based on a given time is:

 

d = 0.5 * g * t^2

 

The multiply by 0.5 is the same as a divide by 2. So, the Y calculation would be:

 

Y=(G*T*T)*0.5

 

Any velocity added to Y would either add to the acceleration. Remember, gravity is always pulling down, so you need at least 9.18 m/s of Y velocity just to get something to move up a little.

 

Y=(VY*T)+((G*T*T)*0.5)

 

The use of cosine and sine convert an angle into the X and Y velocity parts which are constants in the formula once calculated. The *parts* are multiplied by the velocity (or power) value:

 

x-part = cos(angle)

y-part = sin(angle)

 

VX=x-part*POWER

VY=y-part*POWER

 

That's pretty much it. Here is a really nice tutorial if you want some graphics and visuals:

 

http://www.physicsclassroom.com/class/1dkin/U1L5a.cfm

 

  • Like 1
Link to comment
Share on other sites

My goodness but that's a lot of math for such a simple problem. The following will do the trick:

100 CALL CLEAR

110 ANGLE=60::VEL=65

120 RVEL=-VEL*SIN(ANGLE*PI/180):: CVEL=VEL*COS(ANGLE*PI/180)

130 CALL SPRITE (#1,46,2,185,1)

140 CALL MOTION(#1,RVEL,CVEL)

150 RVEL=RVEL+1::GOTO 140

The cannonball travels in a nice parabolic arc. The horizontal velocity doesn't change (it would in the real world due to air resistance) and line 150 adds a steady downward acceleration due to gravity. Of course you need to add CALL COINC or CALL POSITION to detect if you've hit the ground or the target. (This program stops when it hits a bad value for motion) Try entering different angles and initial velocities in line 110. Naturally, in a real game you'd have to adjust the values used here.

  • Like 1
Link to comment
Share on other sites

Thanks Harry ... I'll experiment with that !

 

Oh yeah, thought I might mention - anyone who's into retro programming whatever you do don't download a program called "Tommygun" ... its a cross-dev for spectrum/c64/amstrad that sort of thing - it's only gone and wiped all my text files on my desktop that i was using for TI programs .... also photo's of me and my mum .... im sure the bloody thing is a virus .... funny how i run tommygun and that happens ... anyhow, Twp Big Guns was one of the files ..... nevermind, i can use TI99DIR to extract an existing image file into a notepad entry and rework it again :)

 

It will be ready in a while .... :)

Link to comment
Share on other sites

We had TommyGun up here some time ago. Installed it 17.05.2010 and still it works fine. But sure, there may be some bad copies or download sites out there.

 

I've never deleted a file as fast in my life. Bastard thing :(

 

I've got an old copy of Big Guns back by using TI99DIR ... now that IS a good program hehe

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...