View Full Version : what are photons in C?

04-25-2002, 08:54 AM
man...what does it take to make a simple photon structure?

04-25-2002, 10:29 AM
>man...what does it take to make a simple photon structure?

Brains. A computer. An operating system. A compiler.

If you need help with it, please post more specific information on what you want to do.

04-25-2002, 12:03 PM
whatever. anyway, msdos; c/c++;gaming;borland;the code.

04-25-2002, 12:29 PM
alright, see...i've got this cough cough...disability. i read & took good notes on the entire 1st semester course in C. step by step. i just have this problem...where i have to go back afterwards and study the entire thing all over again...part for part...section for section by any means necessary...and i have most of it understood and in use...it's just i'm one of those people that take 5 years to learn a one semester course. well, it's a learning problem. i need hands on...man, hands on training...i can dooo so much with C...i just cannot make a photon weapon for a spaceship in msdos. i can do it...i've done it six different ways in the past...i want the standard way of creating "bullets" for my spacecraft this time...to bury it into my mind...as permanently as possible...the code...i have to have the code...i'm tired of doing it allllll wrong!!! help, man.

04-25-2002, 12:33 PM
And did you save it the last 6 times you did it? Show us how you did it then. It is always easier to start with something.

>> want the standard way of creating "bullets" for my spacecraft this time<< I don't think the C standard say anything about photon weapons or bullets.

04-25-2002, 12:34 PM
that leaves a lot of questions unanswered. are these bullets fast, or do they scroll across the screen like other projectiles?

if you need help this badly for this, have done it five times before, and still cannot get it, you probably should find another occupation. (or hobby).

04-25-2002, 01:07 PM
well, they sucked. embarrassing. totally. they worked fine. it was back when i was using cleardevice(); like an idiot to make thing animate...just plain ignorant...e.g.

putpixel(x,y,color); it just sucks i cannot even explain it...it would increment x or y, or both...in a plain shooting game firing straight upward...along the x axis. zzz...zzzz...now i have a ship that flies in circles...and i cannot get the bullet to even fly along....ahahahaha i suck sometimes...it's a mental block. i'll try to explain it again later...i just quit smoking cigarettes a week ago...typing kind of get to me right now...i'm going to take a break for bit...it was hit e.g. alt and it would launch the pixel into like an unlocked mode...then from there in the program there would be an incrementation of the y axis. really retarded like.

04-25-2002, 01:11 PM
i'm looking for fast bullets, they were not. actually, this hobby issss very very good for me...you see...i have some gift at it...like with anything else...i'm a god for 2 days...the rest of the week i'm a dolt...like today. i'm this way with everything there is in life....

04-25-2002, 01:32 PM
well, you know...i cannot even beat the games i create these days...they are difficult. i have an imagination. i just have to continue to evolve in my practice...once i gain this photon ability...the evolution can take its toll...and rid my of these programming ills...it's the final process. for god's sakes man...please lend me a hand in my darkest hour...

04-25-2002, 03:52 PM
i don't know what that's all about; i found a thread on the subject of bullets though...so, it's physics? whooooowhooooooooo...big deal. you could have just said so. it's a start.

04-25-2002, 07:02 PM
#include <stdio.h>
#include <math.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
#define rotate 3
#define speed 0.12

typedef struct
float x, y;
} vec;

typedef struct
int num;
vec array[3];
} form;

typedef struct
vec pixel;
int view; // ship direction.
vec move; // move direction.
form make; // make form.
form dos; // screen points.
} image;

image viper;

void array(vec*dest,vec*scr,int degree) // return dest - points to x, y floats.
double rad; // radius.
dest->x=scr->x*cos(rad)-scr->y*sin(rad); // standard library functions.

void mode(image*var) // return value of type image.
int i;
for(i=0;i<var->make.num;i++) // rotate.

void draw(image*var)
int i;

void power(image*var)
var->pixel.x+=var->move.x;var->pixel.y+=var->move.y; // move.
if(var->pixel.x<0)var->pixel.x=var->pixel.x+640; // border.

void hold(){while(inp(0x3da)&8);while(!(inp(0x3da)&8));} // prevent flash.

void init(void)
int GraphicsDriver=VGA;
int GraphicsMode=VGAHI;
viper.make.num = 3;
viper.make.array[ 0 ].x = 0; viper.make.array[ 0 ].y = -16; // coords.
viper.make.array[ 1 ].x = -8; viper.make.array[ 1 ].y = +8;
viper.make.array[ 2 ].x = +8; viper.make.array[ 2 ].y = +8;
viper.view = 0; viper.pixel.x = 320; viper.pixel.y = 240; // center.
viper.move.x = 0; viper.move.y = 0;

void main(void)
int c=0; unsigned short keyboard;
keyboard = *(unsigned short far *)MK_FP( 0x40, 0x17 );
double rad; rad = viper.view*0.01745;


04-25-2002, 07:03 PM
alright, now how do i make this spaceship fire bullets?

04-25-2002, 08:23 PM
by asking nicely and using code tags

and asking the moderator to delete all your nonsense posts

04-25-2002, 08:33 PM
moderator please delete my "nonsense" posts.

04-26-2002, 12:36 AM

First of all, we know nothing about your project. Please sort your thoughts and questions, assume we don't have your knowledge and repost them. Use short sentences and paragraphs, so we can easily follow your train of thought.

What do you want to do ?
What did you do ?
What happened ?
What would you like to change ?

04-26-2002, 03:13 AM
that is the simplest version of the game.
it's finished version is complete with 3 levels of asteroids.
i waited until after creating the asteroids to add weapons.
you ramm them to break them up.
now, i want a weapon to shoot them with.
just nevermind.

04-26-2002, 04:53 AM
i get distracted; & then my logic just shuts off; and i go to sleep.
it's got to be some kind of mental disorder. the question is simple. the answer is too. a pixel that travels from the ship forward view.

04-26-2002, 05:59 AM
Okay, I take a bit of guessing again. Note that if this isn't helpful, you need to give more information, I fire shots in the dark here.

You have a linked list of objects. Maybe two, one for asteroids, one for ship(s). Each object has a speed and a direction. Each object has a graphical representation.
Now make a third kind of object called shot. Keep it in the same storage structure as the asteroids i.e. make it a list of it's own or keep all your objects in one list. Each time your ship fires, create a new object of type shot, with a certain speed and the direction of the ship at this moment. Add it to the list of objects.
Add another run of your collision detection to see when shots hit asteroids and add your routine that simulates asteroids getting hit ( doesn't really matter if hit by ship or shot ). Also, watch for shots going off-screen. These can be removed from the list.

Add the shots to your drawing loop.

04-26-2002, 06:28 AM
that sounds correct; i'll give it a shot. thanks.

04-26-2002, 05:02 PM
i still say it's a pain in the arse...the prog. has everything it needs to make it happen...i mean if you considered the ship as a bullet itself...and then just duplicate it and make it just a pixel....it's now a bullet...right?

04-26-2002, 05:54 PM
to put it in another language: would somebody please change that spaceship into a bullet? please tell me there is a god....

04-26-2002, 05:54 PM
would it help if i told you i'm an ozzy fan?

04-26-2002, 06:06 PM

04-26-2002, 06:10 PM
iron maiden? judas priest?

04-27-2002, 03:18 AM

If your thoughts are as disorganized as your postings here, you will never get it done. Stop it. Think about it. Stay calm. Panic doesn't help you. Shots in the dark won't help you. You need a concept. Make a concept first. Have you read my last post ? Have you implemented it ? If so, how about answering my questions again on this base:

What do you want to do ?
What did you do ?
What happened ?
What would you like to change ?

You will see, these are the questions that you need to answer. If you learn to answer these for yourself, we will be able to help you.

04-27-2002, 12:07 PM
an advice: how abt being a bit low on the use of "."'s. Makes your post and you look real confused.

04-29-2002, 09:32 PM
sorry, i can't help you. i have no idea where to begin. i don't want to read through all that. i don't know you organized your game enviroment. you are the best person to give a solution to your problem.

off the top of my head:

speed of bullet = speed of ship + bullet velocity when ship is at rest
i'm assuming the speed of the bullet is constant, and the bullet has no force against the ship which would cause the ship to slow down.

04-29-2002, 10:11 PM
i'm speechless.

04-30-2002, 12:16 AM
... and for a third time:

>Have you read my last post ? Have you implemented it ?

You are avoiding communication. If you don't want to implement it, tell me. If you have problems to implement it, tell me where. Posting the same question again won't help.

Answers to my questions:

You are doing an Asteroids clone.
You have a spaceship.
You have asteroids.
You have collision detection.
You need bullets.

My solution:
A bullet is created whenever the player presses a key. It has an graphical display of it's own, just like an asteroid or spaceship. It has a set velocity. It has the vector of the spaceship while firing. It moves as everything else does.

What exactly is the part you have problems with ? I can't help you implement it if you don't give details.

04-30-2002, 08:42 AM
I will not tell you how your code should look, because I'm not interested in sticking my head into a pile of DOS code. What I can do is help you with the concept.

You have asteroids. Moving objects.
You have a ship. Moving object.
You want to have shots. Moving objects.

Patterns. Do you see them ?

Each moving object has
a position vector
a velocity vector
an image

You have a bunch of objects moving around your screen. Each time the user presses the key, another object of type 'shot' is added.

Your gameloop might look like this:

while user did not quit and ship did not collide
...for each object,
......check for collisions and handle event
......move object ( position = position + velocity )
......display object
...end each
...if user pressed key
......if key = fire, add new shot to list of objects
......if key = direction, change ships velocity
...end if
end while

If you have problems with this, please post a specific question without code, or a clear coding question that involves not more than ten lines.

05-01-2002, 03:40 AM
as you wish, my lord; i think i have it; just a few small bugs... no big deal to fix...thanks.


05-01-2002, 05:17 AM
Great, good luck with the bugs. If you have problems with them, feel free to post code snippets on the C or C++ boards describing the bug.