Author Topic: Simple Engine Game in Basic  (Read 14346 times)

0 Members and 1 Guest are viewing this topic.

Offline EgoTrip

  • 6128 Plus
  • ******
  • Posts: 1.050
  • Country: gl
    • http://egochip.blogspot.co.uk/
  • Liked: 677
  • Likes Given: 294
Re: Simple Engine Game in Basic
« Reply #125 on: 02:03, 01 January 17 »
Is the INT in lines 320-330 really necessary, as the result is going into an integer variable anyway?
EgoTrip's Stuff
EgoTrip's Stuff

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #126 on: 02:18, 01 January 17 »
No, it's not necessary :)
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.922
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1133
  • Likes Given: 1907
Re: Simple Engine Game in Basic
« Reply #127 on: 08:09, 01 January 17 »
The INT isn't necessary, but I was getting a Subscript out of range error if the brackets were also removed.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #128 on: 00:12, 03 January 17 »
if you like, i've created a Github repository of my project :)

https://github.com/FabrizioRadica/amstrad-platform-basic
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.922
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1133
  • Likes Given: 1907
Re: Simple Engine Game in Basic
« Reply #129 on: 22:17, 04 January 17 »

I was going through a BASIC technical guide on the Wiki last night and discovered using logic conditioning within an IF statement is bad, so made some adjustments to your game:

Code: [Select]

600 IF NOT(INKEY(8)) THEN IF (TEST(x%-8,y%-6)<>9) THEN IF (TEST(x%-8,y%-14)<>9) THEN GOSUB 5000:frcount=2:x%=x%-vx%:GOSUB 5000
700 IF NOT(INKEY(1)) THEN IF (TEST(x%+32,y%-6)<>9) THEN IF (TEST(x%+32,y%-14)<>9) THEN GOSUB 5000:frcount=1:x%=x%+vx%:GOSUB 5000
800 IF NOT(INKEY(0)) THEN IF (TEST(x%,y%+2)<>9) THEN IF (TEST(x%+28,y%+2)<>9) THEN IF walk=1 THEN GOSUB 5000:y%=y%+vy%:GOSUB 5000
900 IF NOT(INKEY(2)) THEN IF (TEST(x%,y%-18)<>9) THEN IF (TEST(x%+20,y%-18)<>9) THEN GOSUB 5000:y%=y%-vy%:GOSUB 5000




I've replaced all the ANDs within the IF statements and made a nested IFs out of it all (as suggested in the guide) and tested this which is definitely faster than a single IF with all the conditioning in it.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #130 on: 23:02, 04 January 17 »
I was going through a BASIC technical guide on the Wiki last night and discovered using logic conditioning within an IF statement is bad, so made some adjustments to your game:

Code: [Select]

600 IF NOT(INKEY() THEN IF (TEST(x%-8,y%-6)<>9) THEN IF (TEST(x%-8,y%-14)<>9) THEN GOSUB 5000:frcount=2:x%=x%-vx%:GOSUB 5000
700 IF NOT(INKEY(1)) THEN IF (TEST(x%+32,y%-6)<>9) THEN IF (TEST(x%+32,y%-14)<>9) THEN GOSUB 5000:frcount=1:x%=x%+vx%:GOSUB 5000
800 IF NOT(INKEY(0)) THEN IF (TEST(x%,y%+2)<>9) THEN IF (TEST(x%+28,y%+2)<>9) THEN IF walk=1 THEN GOSUB 5000:y%=y%+vy%:GOSUB 5000
900 IF NOT(INKEY(2)) THEN IF (TEST(x%,y%-18)<>9) THEN IF (TEST(x%+20,y%-18)<>9) THEN GOSUB 5000:y%=y%-vy%:GOSUB 5000



I've replaced all the ANDs within the IF statements and made a nested IFs out of it all (as suggested in the guide) and tested this which is definitely faster than a single IF with all the conditioning in it.




WOW Fantastic!!!!
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #131 on: 23:08, 04 January 17 »
I was going through a BASIC technical guide on the Wiki last night and discovered using logic conditioning within an IF statement is bad, so made some adjustments to your game:

Code: [Select]

600 IF NOT(INKEY() THEN IF (TEST(x%-8,y%-6)<>9) THEN IF (TEST(x%-8,y%-14)<>9) THEN GOSUB 5000:frcount=2:x%=x%-vx%:GOSUB 5000
700 IF NOT(INKEY(1)) THEN IF (TEST(x%+32,y%-6)<>9) THEN IF (TEST(x%+32,y%-14)<>9) THEN GOSUB 5000:frcount=1:x%=x%+vx%:GOSUB 5000
800 IF NOT(INKEY(0)) THEN IF (TEST(x%,y%+2)<>9) THEN IF (TEST(x%+28,y%+2)<>9) THEN IF walk=1 THEN GOSUB 5000:y%=y%+vy%:GOSUB 5000
900 IF NOT(INKEY(2)) THEN IF (TEST(x%,y%-18)<>9) THEN IF (TEST(x%+20,y%-18)<>9) THEN GOSUB 5000:y%=y%-vy%:GOSUB 5000




I've replaced all the ANDs within the IF statements and made a nested IFs out of it all (as suggested in the guide) and tested this which is definitely faster than a single IF with all the conditioning in it.




Sorry AMSDOS, where i find the Basic techical guide?
Tnx ^_^
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.922
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1133
  • Likes Given: 1907
Re: Simple Engine Game in Basic
« Reply #132 on: 23:18, 04 January 17 »
Yes I found a small segment called "Speeding up BASIC programs" within the Technical information about Locomotive BASIC, apart from the one I made changes to, the other which may apply in your code is the variable after the NEXT. As the article points out though, this can have the disadvantage of compromising good programming style, which I tend to agree strongly about.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #133 on: 23:49, 04 January 17 »
Yes I found a small segment called "Speeding up BASIC programs" within the Technical information about Locomotive BASIC, apart from the one I made changes to, the other which may apply in your code is the variable after the NEXT. As the article points out though, this can have the disadvantage of compromising good programming style, which I tend to agree strongly about.


uhm, i've found this:
[...] Often recurring subroutines (if necessary) should be at the beginning of RAM to speed up things.

so... should i put line 5000 (for example) at the start?
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.922
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1133
  • Likes Given: 1907
Re: Simple Engine Game in Basic
« Reply #134 on: 00:12, 05 January 17 »

uhm, i've found this:
[...] Often recurring subroutines (if necessary) should be at the beginning of RAM to speed up things.

so... should i put line 5000 (for example) at the start?


Unfortunately I don't understand that 1st point, which starts by talking about Avoiding Loops or a Branching program structure if possible, but this last point you're referring to sounds like something different again. I can follow all the other points except this 1st one which is confusing  ???  I've checked with Kevin's original Published article, but it hasn't got the section about Speeding up BASIC Programs, this has been tacked on since by @HAL 6128  :D
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Offline ervin

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.394
  • Country: au
    • index.php?action=treasury
  • Liked: 1081
  • Likes Given: 1258
Re: Simple Engine Game in Basic
« Reply #135 on: 00:17, 05 January 17 »

@Fabrizio
This is looking great!

Just one little thing I noticed... when you drop off a platform and then hold the down arrow key, you'll end up partly stuck in the platform below after landing.
My (cancelled) entry for the CPCRetroDev 2017 Competition http://www.cpcwiki.eu/forum/programming/my-cpcretrodev-2017-entry/
FAST line drawing in CPCtelera http://www.cpcwiki.eu/forum/programming/drawing-lines-with-cpctelera-sdcc/
RUNCPC My entry for the CPCRetroDev 2015 Competition http://www.cpc-power.com/index.php?page=detail&num=12494

Offline Fabrizio Radica

  • Supporter
  • CPC664
  • *
  • Posts: 135
  • Country: it
  • Amiga and CPC6128 User
    • Retroacademy
  • Liked: 128
  • Likes Given: 122
Re: Simple Engine Game in Basic
« Reply #136 on: 00:24, 05 January 17 »
@Fabrizio
This is looking great!

Just one little thing I noticed... when you drop off a platform and then hold the down arrow key, you'll end up partly stuck in the platform below after landing.


yes i know... seems to be the "TEST" inside the "IF" at line 900...
it's a little bug and i'm going to correct it soon ;)
Amstrad CPC6128 <3
http://www.facebook.com/groups/retroacademy/
Retroacademy.it - retrocomputing, retrogame anni &#039;70, &#039;80, &#039;90
Retroacademy.it - retrocomputing, retrogame anni '70, '80, '90

Offline AMSDOS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 3.922
  • Country: au
    • index.php?action=treasury
    • Programs for Turbo Pascal 3
  • Liked: 1133
  • Likes Given: 1907
Re: Simple Engine Game in Basic
« Reply #137 on: 00:55, 05 January 17 »
@Fabrizio
This is looking great!

Just one little thing I noticed... when you drop off a platform and then hold the down arrow key, you'll end up partly stuck in the platform below after landing.


Yes that was ME! I tried correcting it, but don't know what I was doing wrong!  :D
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3