Subject:
|
Re: video game type thing...
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Mon, 12 Mar 2001 20:15:25 GMT
|
Viewed:
|
1417 times
|
| |
| |
Thanks for the response! Now I'm almost ready to test it. I just need to
know if, when you have a call void function, and you then use the int main()
to close the program with return 0;, will the void keep running?
Here's my current copy, without problems, but with the return in a bad place
which I don't like:
#include "conio.h"
#include "dmotor.h"
#include "dsensor.h"
#include "unistd.h"
#define select TOUCH_2
#define right TOUCH_3
#define left TOUCH_1
int MYexit;
int enemy;
int enemies;
int view;
int forward;
int backward;
int left_view;
int right_view;
void fight()
{
/*Put a beep here*/
if(enemy == 1)
{
cputs(" x ");
forward = 1;
right_view = 2;
backward = 3;
left_view = 4;
view = forward;
if(select == 1 && view == 1 && enemies != 0)
{
/*beep*/
sleep(1);
cputs(" ");
enemies = 0;
}
/*if I press the turn right button and I'm not looking left...*/
if(right_view == 1 && view < 4)
{
/*turn 90 degrees*/
view = view + 1;
}
/*if I press the turn right button and I AM looking left...*/
if(right_view == 1 && view == 4)
{
/*turn to the forward view(1)*/
view = 1;
}
/*now let's do the same for left*/
/*if I press the turn left button and I'm not looking left...*/
if(left_view == 1 && view > 2)
{
/*turn -90 degrees*/
view = view - 1;
}
/*if I press the turn left button and I AM looking left...*/
if(left_view == 1 && view == 2)
{
/*turn to the forward view(1)*/
view = 1;
}
}
}
void monitor()
{
while(1 == 1)
{
while(view == 1)
{
cputs(" x ");
}
while(view != 1)
{
cputs(" ");
}
}
while(enemies == 0)
{
while(1 == 1)
{
cputs("Exit");
msleep(500);
cls();
msleep(250);
cputs("Exit");
msleep(500);
cls();
msleep(250);
}
MYexit = 1;
}
}
int main(int argc, char **argv)
{
MYexit = -1;
cputs("x");
enemy = 1;
if(TOUCH_2)
{
if(enemy == 1 && MYexit == -1)
{
fight();
monitor();
}
}
while(MYexit == 1 && MYexit != -1)
{
if(select == 1)
{
return 0;
}
}
return 0;
/*this is the one I want to get rid of, but without it making a fuss*/
}
----------------------------------------------------------------------------
MYexit is just a replacement of exit, which is already defined in one of
those "*.h" things.
Thanks
Nick Howell
|
|
Message has 1 Reply: | | Re: video game type thing...
|
| I worked on that. I'm having trouble with "execi()" and some stuff related to it. Here's the offending area, but not the entire program: int main(int argc, char **argv) { pid1=execi(&startup, 0, NULL, 1, DEFAULT_STACK_SIZE); MYexit = -1; cputs("x"); (...) (24 years ago, 13-Mar-01, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | Re: video game type thing...
|
| (...) I think you mean if (enemy == 1). Also, the identifier "fight" resolves to the address of the fight function. Doing "fight;" is equivalent to doing "1;". It's legal, but it doesn't accomplish anything. You want to do "fight();" and (...) (24 years ago, 12-Mar-01, to lugnet.robotics.rcx.legos)
|
13 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|