Jump to content
IGNORED

Subkiller - new TI BASIC game


Retrospect

Recommended Posts

 

subkiller.thumb.png.66d51f51e77fadfe0f5ff0ce1c51f8bb.png

SUBKILL2 << FIAD file 

  < wav cassette file

 

 

 

***** SUBKILLER *****

 

 

A simple subhunt type game.  I've not seen any for TI Basic so I made one.  Use keys S & D for left and right, and keys 1 & 2 for firing of up to two missiles at once.

The enemy will appear at either side of the screen, and travel right or left.  If you cross the enemy's path it will fire a missile of it's own at you.

 

You score a point with every enemy killed.

 

EDIT: All bugs now fixed,  missiles don't stay on screen after used and score resets to zero with new game. :)

 

Have fun playing one of the slowest subhunt games in history!   :P

 

 

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

Clean simple fun very much in line with the early days of the TI. One suggestion: I would recommend changing the assignment of the left/right keys from S/D to maybe K/L so that the player's hands are not cramped hovering over both the 1/2 keys and the S/D keys as you frequently have to fire a missile and immediately get out of the way.

That wave file by the way is so nostalgic! I now have the urge to go and load up a few cassettes! 😂

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

56 minutes ago, chris36 said:

Nicer than this one :D

Ahh yes I forgot about that one! I think that one was probably one of the C & VG magazine entries, where the artwork was perhaps misleading as to how good the game was.  Mind you it was probably written by a ten year old, at that age I was still wondering how the light switched on and off in the refrigerator.

  • Like 2
  • Haha 1
Link to comment
Share on other sites

2 hours ago, Retrospect said:

Mind you it was probably written by a ten year old, at that age I was still wondering how the light switched on and off in the refrigerator.

Looney Tunes taught me it was a gnome or something what turned that light on and off.  I was off, then, to learn about girls.  I occasionally regret not pondering the fridge light problem longer.

  • Haha 4
Link to comment
Share on other sites

It could be a nice concept start. It remember me the listings games published from the magazines in the eighties where you had the basic structure and the possibility to modify it to improve the game :) 

anyway I have to admit to have tried it in overdrive with classic99, this was my high score ;)

 

image.png.8d0996c05741ff6509febb346668bf82.png

 

@sometimes99er the FIAD file is also present

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

2 hours ago, sometimes99er said:

Could I have the BASIC listing or something ?

SUB KILLER TI BASIC.txt

 

Yep :)     

 

It's a funny coincidence you mention the clouds need to be more random, that listing there , has a better more random cloud routine, as I'd thought of it myself for the 2nd revision.  I've had difficulty with making the player missile go away once it's hit something.  It's only when one of them hits a sub that it happens, it will stay on screen until the next submarine because I've made it do a CALL HCHAR(14,1,106,320) to try to get rid of it.

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

Just a quick nit-pick looking at your code... Hope you don't mind!

 

In the fire routine you have this:

4400 IF F1=1 THEN 4405 ELSE 4499
4405 4405 AA=A1
...
...
4499 RETURN

 

In other words, you want to take the jump to 4499 when F1 is not equal to 1, otherwise you want to just continue. So just say that to the computer and it will do it!

 

4400 IF F1<>1 THEN 4499

 

So by inverting the IF condition we make a nice little optimisation - less code, and therefore (should be) faster.

 

There are quite a few other places where you can make the same optimisation (e.g. line 4600, 4700, 4800, 4900, 4905, 4910, 5000, 31100, 31105, 31150, 31155, 31161).

 

Also, you could combine IFs in some places into a single IF statement, which would be shorter, and potentially faster:

 

Example:

31150 IF F2=1 THEN 31155 ELSE 31199
31155 IF E=1 THEN 31160 ELSE 31199
31160 CALL GCHAR(A2,A4,CH)
...
...
...
31199 RETURN

 

Another way of looking at this is to say "If F2 is not 1, and E is not 1, then just return"

 

You could write as follows:

31150 IF (F2<>1)*(E<>1) THEN 31199
31160 CALL GCHAR(A2,A4,CH)
...
...
...
31199 RETURN

 

These optimisations might not make any noticeable difference, but it just jumped out at me when I was reading the code!

  • Like 2
Link to comment
Share on other sites

2 hours ago, Willsy said:

Just a quick nit-pick looking at your code... Hope you don't mind!

 

In the fire routine you have this:

4400 IF F1=1 THEN 4405 ELSE 4499
4405 4405 AA=A1
...
...
4499 RETURN

 

In other words, you want to take the jump to 4499 when F1 is not equal to 1, otherwise you want to just continue. So just say that to the computer and it will do it!

 

4400 IF F1<>1 THEN 4499

 

So by inverting the IF condition we make a nice little optimisation - less code, and therefore (should be) faster.

 

There are quite a few other places where you can make the same optimisation (e.g. line 4600, 4700, 4800, 4900, 4905, 4910, 5000, 31100, 31105, 31150, 31155, 31161).

 

Also, you could combine IFs in some places into a single IF statement, which would be shorter, and potentially faster:

 

Example:

31150 IF F2=1 THEN 31155 ELSE 31199
31155 IF E=1 THEN 31160 ELSE 31199
31160 CALL GCHAR(A2,A4,CH)
...
...
...
31199 RETURN

 

Another way of looking at this is to say "If F2 is not 1, and E is not 1, then just return"

 

You could write as follows:

31150 IF (F2<>1)*(E<>1) THEN 31199
31160 CALL GCHAR(A2,A4,CH)
...
...
...
31199 RETURN

 

These optimisations might not make any noticeable difference, but it just jumped out at me when I was reading the code!

Here here!

In a language like BASIC, where you can jump anywhere, ELSE can be avoided most of the time using your thinking. 

 

  • Thanks 1
Link to comment
Share on other sites

8 hours ago, Switch1995 said:

Can this be compiled in XB256?

Yes, but if you are going to use XB you would use AND and OR, anyway, plus multiple statement lines, &c.  As @Retrospect is a prolific XB256 programmer, I expect this BASIC project was meant to be a BASIC project without the corruptions of XB or compilation.

 

6 hours ago, TheBF said:

Here here!

In a language like BASIC, where you can jump anywhere, ELSE can be avoided most of the time using your thinking.

Most of the time.  ELSE does have its place.  I sometimes use it in my programs to book-end a section which would otherwise end with a GOTO, or needs to return to a certain point in a test, and such.  In XB, a statement such as  "IF condition THEN line ELSE RETURN" is useful, too, where line is a calculation within the subroutine and condition is the subroutine non-exit condition.

 

I also like using FOR/NEXT loops and manipulating the counter variable to control when the loop exits.  I can do this for tracking players, tracking scores, &c.  The computer performs an implicit IF/THEN for me.

 

 

 

  • Like 4
Link to comment
Share on other sites

I took a brief look at the code for this and there seems to be some things that might speed up the game a bit.

  I noticed that you have multiple calls to CALL KEY to check for user input. I was thinking that a single call to CALL KEY in the game loop would be a better implementation? So the single CALL KEY would check the values of the key pressed and then perform the move left/right/fire action based on the key code instead of a CALL KEY for each.

  It might be faster to check for collisions based on the coordinates of the torpedoes and ships instead of using CALL GCHAR.

  Where you have GOTO LINE_THAT_RETURNS it should be a little faster to just RETURN instead of jumping to a new line and then returning.

  Collision detection should only be performed when the torpedo is on the same Y axis as the ship/sub. So in addition to jumping out with 31100 IF F1<1 OR E<1 OR FY>Y THEN RETURN

And have a separate GOSUB for each collision detection.

 

 

 

 

 

 

Edited by Cheung
Link to comment
Share on other sites

I went ahead and took a stab at making things a little faster. It's been a while since I've done any plain old TI BASIC programming, so I didn't remember that the conditional statements were so limited. I was able to get around not using OR or AND with some old fashioned math. Any who, it's a little bit faster but still not blistering speed

 

 

 

Subkiller.txt

Edited by Cheung
  • Thanks 1
Link to comment
Share on other sites

@Cheung I think I should point out that, before line 1060 in your listing, you misspelled "color".

 

Also, this line

3010 K = ABS(((LM=K)*1)+((RM=K)*2)+((FI1=K)*3)+((FI2=K)*4))

Can also be optimized without ABS (which is slow) as

3010 K = -(LM=K)-(RM=K)*2-(FI1=K)*3-(FI2=K)*4

 

Interesting comparison order you used.  I would normally compare the variable to the constant, i.e. K=FI2

 

Also, the key press detection might be sped up a little by having a string variable (constant) which holds the expected keys, then use POS with your ON-GOSUB.

 

10 CALL CLEAR
11 PRINT "DEFINE YOUR CONTROLS":::
12 INPUT "KEY FOR LEFT MOVE ":Z$
13 K$=Z$
14 INPUT "KEY FOR RIGHT MOVE ":Z$
15 K$=K$&Z$
16 INPUT "KEY FOR FIRE 1 ":Z$
17 K$=K$&Z$
18 INPUT "KEY FOR FIRE 2 ":Z$
19 K$=K$&Z$

REM MORE OPTIMZATIONS POSSIBLE ABOVE
REM 1...2...SKIP A FEW...

3010 K=POS(K$,CHR$(K),1)
3020 IF K=0 THEN 3040
3030 ON K GOSUB 4100,4200,4300,4500

 

NOTE: I updated to fix a bounds-checking problem.  I ain't happy with my solution, now... needs more... finesse.

 

  • Thanks 1
Link to comment
Share on other sites

30 minutes ago, Retrospect said:

Thankyou :)

 

I do appreciate that, because it's all too apparent when i ever do release my source codes that Math is not one of my strongest points.  In fact I do all I can to avoid it.  haha!  

I updated the order that the subroutines are called in this latest edit, shouldn't make much difference but every little bit helps with the TI.

 

Subkiller.txt

Edited by Cheung
  • Thanks 1
Link to comment
Share on other sites

I was able to get it running and compiled on XB256 with some minor changes to the PRINT and INPUT statements. needless to say, the compiled version is way too fast to play. If I have time later this evening, I'll try to get it working correctly when compiled.

  • Like 1
Link to comment
Share on other sites

2 hours ago, Cheung said:

I was able to get it running and compiled on XB256 with some minor changes to the PRINT and INPUT statements. needless to say, the compiled version is way too fast to play. If I have time later this evening, I'll try to get it working correctly when compiled.

If I was compiling it, I would have a set of variables used as timers.  For example, for the player movement, have it ignore the joystick completely unless C1 equals 4 .... ie- C1=C1+1 :: IF C1>3 THEN ..... and set C1 back to nill.  For the submarines movement, the same, C2 used as a timer for those ... and the missiles too would need timers unless you wanted those to be brutally fast.

  • Like 2
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...