From 8fd93665c4a6ec8e1ee134526948bcc7234e5554 Mon Sep 17 00:00:00 2001 From: stevenhowes <38082088+stevenhowes@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:16:09 +0000 Subject: [PATCH] Change fontcolours to colours and added gfx colour changing. Gave stars individual colours and lengths. Player hitbox debug. Rectangle drawing. --- !RunImage,ff8 | Bin 6896 -> 7464 bytes Makefile,fe1 | 4 ++++ c/CTheEscape | 55 +++++++++++++++++++++++++++++++++++++++----------- c/Graphics | 19 +++++++++++++++++ 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/!RunImage,ff8 b/!RunImage,ff8 index bb60eb2fb9538d413966d0a52f97d0036d4729ae..54b9ae1bd98b81577b2de344cc78c6282d74154d 100644 GIT binary patch delta 2947 zcmZ8ie^6A{6+UnGEiB6}JY*4Ae(btL!zeMphz3UME~Ug&gGi$_S_4FWWrjpt(P}5t zT@*3tXoI1U~8=HnAS;6y=hiV%O6e0Nt0~9`*;|} zH*@Bm^PTVBbMC$8+&5h_UgsxLH6c!-shu{O$|3sqWD!w^M8e-)6oU`-hQ#jpySRQ&>wUl@KrkO^2nHT)u<6IM0mzYb*B@XJ6LtQQUc=T@5f6!S-b3<$sL6Ci6b;|P#_f|K(xkf*?r)($2P z0__vL@IQctka^m=!NfkG-B_1=s)k)_YgenfRZ;a@;Ov2~?LMCj-*x!vFh3php9ANc zb2#owL<8p!;M_7JcYxFMC1<{71IYr?Z$T=3T-Bcfq0va~O(4s#v;_%o0=nwUXnu23Cgb2zi>M8TObIV-@y^@Q)8gCL28j)U}(NqQKh z!Z{0dfFsW82sjJjn|Gg2oYfF~i^RO8s%|S$^-C6-`U>jxJ>cbnPnEhdzBQv3SlsHS zsi#TRMIi~tJ60<4%500=mDk<=Y-ejnsQufmeZB4bIzyt!-A6CxhW{(m`MpY%?+rw` zOe376qyHq|2(K?!HH$LBg9WN~7(u^9QEsPUejU2NCE&tWD(2W#E%3-doMv^{#aP3F zHR{VFaZhZ7J1?u+x`Kg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qTI!;`*1n#dF9!m~TX30Le?;78YTyM&T;dpqkx*x^ChlOD@- zdeICas|QuXqcKd8nt3n&9RG!#LMo9G#TnQJe*;X#B`s(1PFLt1jP4_r?M#(UvodGC zd`@O3oSsx>R>WQ|;XSAYd(lDYbKIbwiPODga+>i_W{;dh63$v-555X*@l&m)cgt*a z#1O|Ri@GhdyofAm1=|ua(y;(pc|F;{-DpE)9DO5<5!*Qnn*%WK504Yy~5Q z`TV^S`!UMn7=mpQa-Gd&e?@tQ-}d6Xa77|VwWYj;DIYCwuy5A!_2k zqNMY~6pDpBii5Uep@Ds7wc)_1YI%s2RlARqKYEL=Eh~~oxDgr(JmqdW`{Xp{{ceS+amw~ diff --git a/Makefile,fe1 b/Makefile,fe1 index 8c7020a..ced36f4 100644 --- a/Makefile,fe1 +++ b/Makefile,fe1 @@ -42,6 +42,10 @@ o.Graphics: c.Graphics o.Graphics: C:h.swis o.Graphics: C:h.kernel o.Graphics: C:h.kernel +o.Graphics: c.Graphics +o.Graphics: C:h.swis +o.Graphics: C:h.kernel +o.Graphics: C:h.kernel o.CTheEscape: c.CTheEscape o.CTheEscape: C:h.swis o.CTheEscape: C:h.kernel diff --git a/c/CTheEscape b/c/CTheEscape index de5fef8..87f9efe 100644 --- a/c/CTheEscape +++ b/c/CTheEscape @@ -30,8 +30,8 @@ char hudbuffer[63]; enum font_e{sys_12_8,font_max}; -enum fontcolour_e{lcars_black,lcars_violet1}; -int fontcolours[] = {0x11111000,0xc4727200}; +enum colour_e{lcars_black,lcars_violet1,hotpink,stargrey1,stargrey2,stargrey3}; +int colours[] = {0x11111100,0xc4727200,0xcc00ff00,0x66666600,0x22222200,0x44444400}; int font[font_max]; struct EntityLocation_s { @@ -44,6 +44,13 @@ struct NPC_s { unsigned char velocity; }; +struct Star_s { + struct EntityLocation_s location; + int colour; + unsigned char length; +}; + + struct Player_s { struct EntityLocation_s location; enum sprite_e sprite; @@ -51,11 +58,13 @@ struct Player_s { int shields; int integrity; int remainingdistance; + struct EntityLocation_s hitbox_bl; + struct EntityLocation_s hitbox_tr; }; struct NPC_s NPCS[MAX_NPCS]; struct Player_s Player; -struct EntityLocation_s Stars[MAX_STARS]; +struct Star_s Stars[MAX_STARS]; int tick = 0; int lasttick = 0; @@ -138,13 +147,27 @@ void intro() void game_draw_player() { draw_sprite(sprites[Player.sprite], Player.location.X, Player.location.Y); + + graphics_colour(colours[hotpink]); + + // Bounding box debug + draw_rectangle( + Player.location.X + Player.hitbox_bl.X, + Player.location.Y + Player.hitbox_bl.Y, + Player.location.X + Player.hitbox_tr.X, + Player.location.Y + Player.hitbox_tr.Y + ); } void game_draw_stars() { unsigned char i; + + + for(i = 0; i <= MAX_STARS; i++) { - draw_line(Stars[i].X,Stars[i].Y,Stars[i].X,Stars[i].Y+30); + graphics_colour(Stars[i].colour); + draw_line(Stars[i].location.X,Stars[i].location.Y,Stars[i].location.X,Stars[i].location.Y+Stars[i].length); } } @@ -157,6 +180,10 @@ void game_setup_player() Player.shields = 100; Player.integrity = 50; Player.remainingdistance = 1500000; + Player.hitbox_bl.X = 0; + Player.hitbox_bl.Y = 0; + Player.hitbox_tr.X = 60; + Player.hitbox_tr.Y = 81; } void game_tick_stars() @@ -164,11 +191,13 @@ void game_tick_stars() unsigned char i; for(i = 0; i <= MAX_STARS; i++) { - Stars[i].Y -= (tick - lasttick) * 2; - if((Stars[i].Y + 30) <= 0) + Stars[i].location.Y -= (tick - lasttick) * 2; + if((Stars[i].location.Y + Stars[i].length) <= 0) { - Stars[i].X = rand() % DISPLAY_X; - Stars[i].Y = DISPLAY_Y + 30; + Stars[i].colour = colours[stargrey1 + (rand() % 2)]; + Stars[i].length = 30 + (rand() % 10); + Stars[i].location.X = rand() % DISPLAY_X; + Stars[i].location.Y = DISPLAY_Y + Stars[i].length; } } } @@ -178,8 +207,10 @@ void game_setup_stars() unsigned char i; for(i = 0; i <= MAX_STARS; i++) { - Stars[i].X = rand() % DISPLAY_X; - Stars[i].Y = rand() % DISPLAY_Y; + Stars[i].colour = colours[stargrey1 + (rand() % 2)]; + Stars[i].length = 30 + (rand() % 10); + Stars[i].location.X = rand() % DISPLAY_X; + Stars[i].location.Y = rand() % DISPLAY_Y; } } @@ -234,14 +265,14 @@ void game_draw_hud() { draw_sprite("lcars",4,DISPLAY_Y-180); - font_colour(fontcolours[lcars_black],fontcolours[lcars_violet1],font[sys_12_8]); + font_colour(colours[lcars_black],colours[lcars_violet1],font[sys_12_8]); draw_text("Shields",75,DISPLAY_Y-62,font[sys_12_8]); draw_text("Integrity",75,DISPLAY_Y-92,font[sys_12_8]); draw_text("Velocity",75,DISPLAY_Y-122,font[sys_12_8]); draw_text("Distance",75,DISPLAY_Y-152,font[sys_12_8]); - font_colour(fontcolours[lcars_violet1],fontcolours[lcars_black],font[sys_12_8]); + font_colour(colours[lcars_violet1],colours[lcars_black],font[sys_12_8]); sprintf(hudbuffer,"%i",Player.shields); draw_text(hudbuffer,230,DISPLAY_Y-62,font[sys_12_8]); diff --git a/c/Graphics b/c/Graphics index 5ce6e2c..0a2bc5d 100644 --- a/c/Graphics +++ b/c/Graphics @@ -77,6 +77,15 @@ void draw_line(int x1,int y1,int x2,int y2) inreg.r[2] = y2; _kernel_swi(OS_Plot,&inreg,&outreg); } + +void draw_rectangle(int x1,int y1,int x2,int y2) +{ + draw_line(x1,y1,x1,y2); + draw_line(x1,y1,x2,y1); + draw_line(x2,y2,x2,y1); + draw_line(x2,y2,x1,y2); +} + void draw_sprite(char* spritename,int x, int y) { // SpriteOp 34 to put sprite at a location @@ -124,6 +133,16 @@ void font_colour(int fg, int bg, int fonthandle) _kernel_swi(ColourTrans_SetFontColours, &inreg, &outreg); } +void graphics_colour(int setcolour) +{ + inreg.r[0] = setcolour; + inreg.r[1] = -1; + inreg.r[2] = 0; + _kernel_swi(ColourTrans_ReturnColourNumberForMode,&inreg,&outreg); + inreg.r[0] = 0; + inreg.r[1] = outreg.r[0]; + _kernel_swi(OS_SetColour,&inreg,&outreg); +} void screen_flipbuffer() { inreg.r[0] = 19;