MIPS assembly language snake projectMIPS assembly language snake project

write a MIPS assembly language program for a snake project using the c code under

a#include <conio.h>

#include <stdio.h>

#include <unistd.h>

#include <stdlib.h>

int t, n, h = 20, wid = 20;

int done, achievement;

int w, q, foodw, foodq, status;

void enviroment()

{

done = 0;

w = h / 2;

q = wid / 2;

labe11:

foodw = rand() % 20;

if (foodw == 0)

goto label2;

label2:

foodq = rand() % 20;

if (foodq == 0)

goto label2;

achievement = 0;

}

void design()

{

system(“cls”);

for (t = 0; t < h; t++) {

for (n = 0; n < wid; n++) {

if (t == 0 || t == wid – 1

|| n == 0

|| n == h – 1) {

printf(“-“);

}

else {

if (t == w && n == q)

printf(“0”);

else if (t == foodw

&& n == foodq)

printf(“*”);

else

printf(” “);

}

}

printf(“\n”);

}

printf(“achievemnt = %d”, achievement);

printf(“\n”);

printf(“press X to quit the game”);

}

void play()

{

if (kbhit()) {

switch (getch()) {

case ‘a’:

status = 1;

break;

case ‘s’:

status = 2;

break;

case ‘d’:

status = 3;

break;

case ‘w’:

status = 4;

break;

case ‘x’:

done = 1;

break;

}

}

}

void logic()

{

sleep(0.01);

switch (status) {

case 1:

q–;

break;

case 2:

w++;

break;

case 3:

q++;

break;

case 4:

w–;

break;

default:

break;

}

if (w < 0 || w > h

|| q < 0 || q > wid)

done = 1;

if (w == foodw && q == foodq) {

label003:

foodw = rand() % 20;

if (foodw == 0)

goto label003;

label004:

foodq = rand() % 20;

if (foodq == 0)

goto label004;

achievement += 10;

}

}

void main()

{

int m, ph;

enviroment();

while (!done) {

design();

play();

logic();

}

}

Calculate your order
Pages (275 words)
Standard price: $0.00
Client Reviews
4.9
Sitejabber
4.6
Trustpilot
4.8
Our Guarantees
100% Confidentiality
Information about customers is confidential and never disclosed to third parties.
Original Writing
We complete all papers from scratch. You can get a plagiarism report.
Timely Delivery
No missed deadlines – 97% of assignments are completed in time.
Money Back
If you're confident that a writer didn't follow your order details, ask for a refund.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00
Power up Your Academic Success with the
Team of Professionals. We’ve Got Your Back.
Power up Your Study Success with Experts We’ve Got Your Back.