Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Colour Maximite 1 & 2 BASIC Programming Challenge 2021
Page 2 of 8 | |||||
Author | Message | ||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2870 |
Hi Vegepete, Dont forget to submit it to the official email address (listed in the rules) mailto: cmmprogrammingchallenge@gmail.com And NO!, I have no idea what it does until I run it. Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
PilotPirx Regular Member Joined: 03/11/2020 Location: GermanyPosts: 66 |
Hi Vegipete, wow, the first game i had on my Sinclair ZX80!! (only Assembler and B/W) Very good and short programming. I love it. I'll never be a good programmer, sigh! |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
@vegipete You've set an impressive bar, and I did guess correctly, from the name, not the code. Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
vegipete, I tested it and it's very impressive! Congratulations! Edited 2021-02-12 20:26 by MauroXavier |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3550 |
Edited 2021-02-15 03:40 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Here is a minor update to In Defence of the Green Hills of Earth. No visible changes, just some slight internal adjustments. Included is an expanded and heavily commented version, over 400 lines long, although more than 25% is 'educational' commenting at the beginning, explaining some of the theory behind my perverse programming. Interestingly, the expanded version has shown me a few 'faults' in the code - unnecessary chunks that serve no purpose. However, it's all retained in its glory. --- Edit: I see an omission in the comments around line 77: "The result can only be 0 if both conditions are false. They cannot both be true." . Edited 2021-02-16 06:30 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
Turbo46 Guru Joined: 24/12/2017 Location: AustraliaPosts: 1593 |
Thanks for that vegiepete. Much appreciated. Bill Keep safe. Live long and prosper. |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
It was very curious reading the vegipete source today and see that I did some implementations in the same way, but always with a code less readable (sorry! I really need to educate myself about this). Soon I will publish my source to the contest too... But compared to the vegipete, my code is a f* mess, using almost all 4800 characters heavily compressed, and it isn't because I wanted the things to be like this, but is because I needed to do this way to put all the effects. At all times of the programming, I was tormented with thoughts like: - "But what if I put this effect here or there?". So when I tried to make the job I always got me not having more space on the screen, forcing me to challenge myself more and more until exhaustion (seriously!). But unfortunately, the final result is a source code unintendedly obfuscated to fit it in the purpose of 4800 characters. For sure I will don't get one single point for Clarity in the contest, but I consider it a sacrifice too. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Whilst we don't object, and actively encoourage, entries being posted to TBS can I also please ask contestants to send their contribution to the official email address cmmprogrammingchallenge@gmail.com as only those will be considered official entries. Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
I already sent the e-mail to the contest as the instructions. For the forum members, here is my code and submitted text: Game name: HOPE ROBOT DIM XP(2),YP(2),FX(4),FY(4),FA(4),FD(4),FS(4),PX(99),PY(99),CX(99),CY(99),PA(99),PM(99),PP(99):L=.1 SUB PR F,T,X,Y,C,O,A$,Z,S:PG 1:FONT #F,T:COLOR S:FOR ZA=-Z TO Z+1:FOR ZB=-Z TO Z:?@(X+ZA,Y+ZB,1) A$; NEXT:NEXT:COLOR O:?@(X+1,Y,1) A$;:COLOR C:?@(X,Y,1) A$;:END SUB:OPTION ANGLE DEGREES:YW=10^8:R=7.8^8 SUB HR:IF TIMER MOD (((LF\50)+1)*290)<200 OR LF=0 THEN PLAY SOUND 4,B,Q,900,10 ELSE PLAY SOUND 4,B,O END SUB:SUB MT C:SN C,"O",1:END SUB:SUB PG T:PAGE WRITE T:END SUB:XX=640:YY=400:TC=&HFF2800:W=10^8.4 SUB SN C,P$,F,V:EXECUTE "PLAY SOUND "+STR$(C)+",B,"+P$+","+STR$(F)+","+STR$(V):END SUB:MODE 2,8:DO YD=7763456:V=V+1:Y=200:LF=Y-V*2:DN=300:U=4^11::GO=0:SETTICK 0,HR:PLAY STOP:X=0:IF SV=0 THEN SC=0:V=2 YB=50^4:DO WHILE KEYDOWN(1)<>32 AND SV=0:PG 1:CLS 99:T=COS(I)*1+1:PR 3,3,82,145,R,R,"HOPE ROBOT",T,R PR 7,2,4,4,W,W,"HIGH SCORE:"+FORMAT$(HS,"%06.0f"),2:S=T*99:PR 7,2,238,DN,S,S,"PRESS SPACE",2:I=I+30 PR 1,1,230,385,W,W,"MAURO XAVIER - 2021",2:PAGE COPY 1 TO 0:SN 1,"T",T*75+1,25:LOOP:CLS TC:PG 2:SV=0 MS$="GAME OVER":DD=0:S=65:MATH SET 0,FA():MATH SET 0,PA():SETTICK 25,HR:AN=0:TIMER=0:UP=99:CLS TC BOX 0,170,XX,60,0,,U:DO WHILE LF>=0:PG 2:UP=UP+RA:IF UP<20 THEN UP=20 ELSE IF UP>DN-80 THEN UP=DN-80 RA=RND*10-5:RB=RND*10-5:IF WL<1 THEN:CP=U:ENDIF:IF DN<UP+80 THEN DN=UP+80 ELSE IF DN>380 THEN DN=380 BOX XX-M,0,M,YY,0,,TC:BOX XX-M,UP,M,DN-UP,0,,CP:M=V+X\35:WL=WL-1:DG=G*H:DN=DN+RB:CP=YD:PG 1:SX=0:N=3 SY=0:FOR T=0 TO XX STEP 30:DG=DG+6:BLIT T,0,T,COS(DG)*8,30,YY,2,0:NEXT:IF TIMER>999 AND LF>0 THEN PAGE SCROLL 2,-M,0,0:FOR T=1 TO 4:K=KEYDOWN(T):IF K=32 AND F=0 THEN:F=1:ENDIF:IF K=128 THEN:SY=-N ELSEIF K=129 THEN:SY=N:ENDIF:IF K=130 THEN:SX=-N:ELSEIF K=131 THEN:SX=N:ENDIF:NEXT:GO=1:ELSE:EN=0 ENDIF:D=D+SY:EG$="N":TT=M-V:X=X+S/10:Y=Y+D/10:SN 1,EG$,(10-S\12)\3+TM,9:IF X<0 AND DD=0 THEN X=0:S=0 TX$="SAVED":IF S>0 THEN:S=S-1:ELSEIF S<0 THEN:S=S+1:ENDIF:IF D<-40 THEN D=-40 ELSE IF D>40 THEN D=40 B=255:SW=G MOD 2:IF X>610 THEN:SX=-4:ENDIF:IF SY=0 THEN IF D>0 THEN:D=D-1:ENDIF:IF D<0 THEN INC D XP(1)=X+COS(D+120)*TM:S=S+SX:XP(0)=X+COS(D)*20:XP(2)=X+COS(D+240)*TM:YP(0)=Y+SIN(D)*20:CN=&HFF00BF YP(1)=Y+SIN(D+120)*TM:YP(2)=Y+SIN(D+240)*TM:POLYGON 3,XP(),YP(),0,&HBBBB:SS=S:IF SS<-5 THEN SS=-5 XP(0)=X-COS(D)*(SS+M*7):YP(0)=Y-SIN(D*2)*20:PG 1:MT 2:IF SW THEN POLYGON 3,XP(),YP(),U,RGB(127,0,0) ENDIF:SC=SC+IS::IS=M/50+SV*50:IF EN=0 THEN:IF RND<0.01 THEN:ER=0:YE=UP+20+RND*(DN-UP-20):XS=-RND*V XE=649:YS=RND*6-3:EN=GO:ENDIF:ELSE:INC ER,15:EA=COS(ER)*4+15:INC XE,XS-M:IF XE<X THEN A=L ELSE A=-L INC YE,YS:IF YE<Y THEN:C=L:ELSE:C=-L:ENDIF:INC XS,A:INC YS,C:Q=Q+YS:K=0:FOR T=Q TO 360+Q STEP 20 A=-COS(T)*EA:C=-SIN(T)*EA:LINE XE,YE,XE-A*1.4,YE-C*1.4,1,W:O=PIXEL(XE-A,YE-C): IF O=TC OR O=YD THEN INC XS,A/5:INC YS,C/5:INC XE,A:INC YE,C:MT 3:ENDIF:NEXT:CIRCLE XE,YE,EA,1,1,0,CN:SN 3,"T",EA*15,20 ENDIF:IF XE<0 OR XE>649 THEN:EN=0:MT 3:ENDIF:FOR T=1 TO 4:A=X+COS(D)*35:IF KEYDOWN(T)=32 THEN K=2 IF FA(T)=1 THEN:INC FY(T),FD(T):INC FX(T),14-TT:INC FS(T),-1:IF FX(T)>XX OR FY(T)<0 OR FY(T)>YY THEN FA(T)=0:ENDIF:PG 1:LINE FX(T)-30,FY(T)-FD(T)*2,FX(T),FY(T),1,YW:IF FS(T)>1 THEN SN 2,"W",FS(T)*50,25 FOR E=1 TO 9:O=PIXEL(FX(T)+E,FY(T)):IF FX(T)<XX AND (O=TC OR O=CN OR O=YD) THEN:PC=YB:A=3:FA(T)=30 IF O=TC THEN:PC=R:H=25:A=-8:ELSEIF O=CN THEN:IS=150:MT 3:A=25:EN=0:PC=7.3^8:ENDIF:LF=LF+A:EXIT FOR ENDIF:NEXT E:ENDIF:IF FA(T)>1 THEN:PG 1:C=FA(T)*8+9:INC FX(T),-M:A=RGB(C,C,C):SN 3,"N",61-FA(T)*2,25 INC FA(T),-3:CIRCLE FX(T),FY(T),33-FA(T),1,1,YW,A:IF FA(T)<3 THEN:PG 2:CIRCLE FX(T),FY(T),32,1,1,U,U MT 3:FA(T)=0:ENDIF:I=0:P=0:DO WHILE I<=39 AND P<10:IF PA(I)=0 THEN:PA(I)=1:PM(I)=0:CX(I)=RND*7-5 CY(I)=RND*8-4:INC P:PP(I)=PC:PX(I)=FX(T):PY(I)=FY(T)+(YY-FY(T))/99:ENDIF:INC I:LOOP:ENDIF:PG 2 IF FA(T)=0 AND F=1 THEN:F=2:FY(T)=Y+SIN(D)*50:FA(T)=1:FX(T)=A:FD(T)=D/2:FS(T)=10:EXIT FOR:ENDIF:NEXT F=K:ENDIF:TM=COS(AN)*4+9:IF RND>0.99 AND GO THEN:WL=9:ENDIF:IF LF>350 THEN SV=1:LF=350:MS$=TX$+"!!" H=H-L:FOR I=0 TO 39:IF PA(I)=1 THEN:INC PY(I),CY(I):INC PX(I),CX(I)-M:PG 2:IF PX(I)<0 THEN PA(I)=0 J=PP(I):O=PIXEL(PX(I),PY(I)):IF O=TC OR O=YD THEN:CX(I)=-CX(I)/4:INC PM(I):CY(I)=-CY(I)/4 IF PM(I)>5 THEN:PA(I)=0:CIRCLE PX(I),PY(I),4,1,1,J,J:ENDIF:ENDIF:PG 1:CIRCLE PX(I),PY(I),4,1,1,J,J ENDIF:ENDIF:NEXT I:FONT #3,3::FOR T=0 TO 360 STEP 45:A=-COS(T)*15-5:C=-SIN(T)*TM:I=PIXEL(X-A,Y-C) IF I=TC OR I=CN OR I=YD THEN:S=S+A:D=D+C:EG$="W":LF=LF-1:ENDIF:NEXT:IF LF<1 OR SV=1 THEN:EN=0:D=0 LF=SV*300:IF DD=0 THEN:PLAY STOP:TIMER=0:ENDIF:PR 3,3+SV,95,145,YW,B,MS$,3,B*SW:IF TIMER>4^6 THEN LF=-1:ENDIF:S=0:DD=1:ELSE:PR 1,1,11,16,W,B,"LIFE",1:BOX 50,18,LF,9,1,0,B:LF=LF-L:BOX 50,18,350,9,1,W ENDIF:PR 1,1+DD*2,11,4,W,B,"SCORE:"+FORMAT$(SC,"%06.0f")+" "+TX$+":"+STR$(V-2),1+DD:G=1+G MOD 360 INC AN,M*3:T=14-LF\10:IF H<=T THEN:H=T:ENDIF:PAGE COPY 1 TO 0,I:LOOP:IF SC>HS THEN:HS=SC:ENDIF:LOOP DESCRIPTION You are a testing prototype nanomachine called "HOPE ROBOT", which is the last hope of humanity to extinguish virus plague that spread to all the world. Navigate inside human bodies and save patients in this nano adventure for your Colour Maximite 2. INSTRUCTIONS Press SPACE to fire and directional keys to move your robot, but be careful, your nanomachine is moving inside a body and you should not shot in the human tissues, you must exterminate all viruses and unblock all passages to relieve the blood circulation. You start at a middle scenario inside a patient, and as eliminating the blocked passages and viruses the life will be restored and you hear the heartbeat stabilising. If you delay doing anything, life decreases with time and if you shot in human tissues you will hurt the patient, decreasing the life and disestablishing the heartbeat. The game is over if the life bar reaches the end. If you fill the life bar then you saved the patient and will restart inside another human body to save it again, but with each patient saved, the difficulty will be increased. You will gain a little score while keeping the patient alive, but the main score is focused on killing viruses and saving patients. Good luck, you are our HOPE ROBOT! OBSERVATIONS ABOUT DEVELOPMENT This game was developed totally focused to keep the rules of this contest but unfortunately was impossible to keep a minimum of clarity of the code or a single comment. All algorithm is propositionally out of order and is heavily unorganized, but was not my intention obfuscate it, but to gain every single extra character to fulfil my target: give the best experience I can give to the users at 48x100 characters limitation. Edited 2021-02-18 10:23 by MauroXavier |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
Wow Mauro, that is a seriously awesome effort! A couple of observations: Line 43 start with two ENDIFs - I think you only need one. You could change your high score test at the end (IF SC>HS THEN:HS=SC:ENDIF) to HS=MAX(HS,SC) to save some space. Beautiful program! I really like the spray of exploding circles. So much for me to study. Your amazing work shows just how much the CMM2 can do. Visit Vegipete's *Mite Library for cool programs. |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
vegipete, thanks for your recommendations! This saved space can help me to put a thing again. I never used the MAX command, and this shows that I must read the manual to learn about some commands that I not used before. There were so many things that I removed... Maybe with a little more tricks, I can put it in place again. After I consider the code as the final version for the contest, then I will organize, put comments, and release an enhanced version of "HOPE ROBOT+" with all the implementations that I would like to have done. |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
I may have some more savings for you. I wanna see even more tricks! (The line numbers for the ideas below refer to your listing above.) I'm not sure of this one but it could give you a bit (It might not handle multiple key presses correctly): lines 16 and 17, compressed: PAGE SCROLL 2,-M,0,0:FOR T=1 TO 4:K=KEYDOWN(T):IF K=32 AND F=0 THEN:F=1:ENDIF:IF K=128 THEN:SY=-N expanded, with possible alterations:ELSEIF K=129 THEN:SY=N:ENDIF:IF K=130 THEN:SX=-N:ELSEIF K=131 THEN:SX=N:ENDIF:NEXT:GO=1:ELSE:EN=0 PAGE SCROLL 2,-M,0,0 FOR T=1 TO 4 K=KEYDOWN(T) IF K=32 AND F=0 THEN:F=1:ENDIF IF K=128 THEN SY=-N ' end of line 16 ELSEIF K=129 THEN SY=N ENDIF 'SY=SY+(K=129)-(K=128) ' ####### replaces previous 5 lines IF K=130 THEN SX=-N ELSEIF K=131 THEN SX=N ENDIF 'SX=SX+(K=131)-(K=130) ' ####### replaces previous 5 lines NEXT SX=40*SGN(SX) ' ####### add this statement SY=40*SGN(SY) ' ####### add this statement GO=1:ELSE:EN=0 In line 19, change IF S>0 THEN:S=S-1:ELSEIF S<0 THEN:S=S+1:ENDIF to S=S-SGN(S) In line 20, change IF D>0 THEN:D=D-1:ENDIF:IF D<0 THEN INC D to D=D-(D>0):D=D+(D<0) In line 26, change IF YE<Y THEN:C=L:ELSE:C=-L:ENDIF to C=L*(2*(YE<Y)-1) End of line 40, change (test this one carefully) IF PX(I)<0 THEN PA(I)=0 to PA(I)=(PX(I)>=0) Visit Vegipete's *Mite Library for cool programs. |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
You have very impressive logical reasoning. I learned a lot from your tips, I'll apply them and take a closer look to see if I apply some more (In variable D it was possible to apply SGN too). For sure you will see other things implemented thanks to you. |
||||
MauroXavier Guru Joined: 06/03/2016 Location: BrazilPosts: 303 |
This part doesn't work well: SX=40*SGN(SX) SY=40*SGN(SY) But using your trick, I changed the keyboard controller part to: SX=SX+((K=131)-(K=130))*N:SY=SY+((K=129)-(K=128))*N And worked very well! |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
I'm not sure why I put '40' there - should have been 'N'. You are right. Opposite arrow keys will cancel each other. I had that to begin with but confused myself and changed it and added the "40*SGN" bit. I'm looking forward to more awesomeness with Hope Robot! Visit Vegipete's *Mite Library for cool programs. |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
I looked at D a bit, didn't immediately see anything. Now I did spot something: Change (end of line 19) IF D<-40 THEN D=-40 ELSE IF D>40 THEN D=40 toD=MAX(-40,MIN(40,D)) Visit Vegipete's *Mite Library for cool programs. |
||||
thwill Guru Joined: 16/09/2019 Location: United KingdomPosts: 3848 |
Hi folks, With only one month to go there has been exactly ... ... ONE entry sent to the official email address cmmprogrammingchallenge@gmail.com - and the crowd goes wild with excitement . Best wishes, Tom Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3660 |
I hope it isn't disqualified LOL John |
||||
Volhout Guru Joined: 05/03/2018 Location: NetherlandsPosts: 3550 |
@Vegipete Wauw, that is clever coding. Tried it in DOS MMBasic, and it really works. I take my hat off. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Page 2 of 8 |
Print this page |