# Fenix Code Help

#### Moogle

##### .
If you look at the code and what has changed for the waiting part I'm sure it wouldn't be that hard to add what you want After all, that's the idea of learning programming .

#### look

##### N/A
Anyone got any ball motion/physics example code.

I got a pitch and a player but no dang ball for my footy game

#### Moogle

##### .
The bouncing principle is very easy, incoming angle = outgoing angle, you may need to be a little more specific what you want to know.

Code:
``````PROGRAM bal;

GLOBAL
speedo = 10;

BEGIN

set_mode(m320x240);

graph = new_map(20,20,8);
map_clear(0,graph,10);
x = 160; y=120;

loop

angle = -angle + 180000;
end

angle = -angle;
end

if(key(_enter))
angle = rand(0,360)*1000;
end

frame;
end

END``````

#### Sonic-NKT

##### Very Active Member
If you look at the code and what has changed for the waiting part I'm sure it wouldn't be that hard to add what you want After all, that's the idea of learning programming .
thats right...
will try it, if i cant get in the end of the weekend i will ask again

Last edited by a moderator:

#### look

##### N/A
The bouncing principle is very easy, incoming angle = outgoing angle, you may need to be a little more specific what you want to know.

Code:
``````PROGRAM bal;

GLOBAL
speedo = 10;

BEGIN

set_mode(m320x240);

graph = new_map(20,20,8);
map_clear(0,graph,10);
x = 160; y=120;

loop

angle = -angle + 180000;
end

angle = -angle;
end

if(key(_enter))
angle = rand(0,360)*1000;
end

frame;
end

END``````

Ta very much

I'll have a play and get back with specifics if needs be.

Just wanted a kick in the ass to start me off

EDIT: its a square ball.....now theres a gimmick

Last edited by a moderator:

#### Nilsiboy

##### 1337 T045T
hi guys,
I just started to code in fenix and already got to my first bunch of problems...solved most of them, but two are left:
1. i make the players ship expand on a button press, but while it's expanding, it can't move, as its in the ship process....i tried setting up a single process for it and it didnt work either ]=
2. how can i make a ball (or bullet) that bounces from a wall/ship/object in general aim to a certain position (or even better, to an area around that position) ?

#### saintdragon

##### Member
ok the only tutorials i have done are ED's ones, and i want to make a realy simple remake of a game like 2 color pong.

can u tell me where to find a really well docmented tutorial of a simple game please.

#### Moogle

##### .
charga_man: There actually is a fully documented sourcecode of a basic pong game in the sourcecode pack on the File Archive, check here.

Nilsiboy:

Let's see,
1. It's a matter of how you are expanding it. If you make in the ship code a structure like this:
Code:
``````while(key(__A))
//expand
frame;
end``````
you can be sure it won't move. Better would be a structure like this
Code:
``````if(key(__A))
//expand
end``````
the game won't stop. Maybe I'm looking not far enough, if so then specify the problem some more

2. What do you want? If you want it to bounce, then the outgoing angle is based on the incoming angle. If you want to make it go to a certain position it's not really bouncing, it's changing angle. In case of the last one you can use the command

fget_angle(x1,y1,x2,y2)

which returns the angle from one point to another point. If you want to direct it to the relative position you might want to add a random amount of angle 'garbage' to the angle returned.

#### Nilsiboy

##### 1337 T045T
for expanding:
i have the expanding in the ship's code, with an if, but a bit more complicated, because there aer two possibilities: "ship is black" and "ship is white"
i would appreciate a tip how to put the expanding into an own piece of codethat is just started when i press a and runs simultanously

for the "bouncing":
so i had to get the target's coordinates first? because i want to do something like if the shot bounces from your ship, it flies ca. in direction of an enemy. as all enemies would be made by one process, is it possible to seperate them andrandomize on which it aims?

#### Moogle

##### .
for expanding:

Calling another process for the expanding could cause chaos when you press the button multiple times. In-code you could do something like this:
(just an example, these kind of programming problems can be solved in hundreds of ways)
Code:
``````//If pressed the A button, give room to expand to 150%
if(key(__a)))
expandTo = 150;
end

//If expand does not equal expandTo, go towards equality
if(expand > expandTo)
expand -=5;
else
if(expand < expandTo)
expand += 5;
end
end

//If expand is maximal, it must be equal to expandTo, so expandTo can be
//set back to 100 to shrink the size again
if(expand == 150)
expandTo = 100;
end

//And make sure the size grows as expand does(or do something else)
size = expand;``````

for bouncing:
Programming problem again, implementation could be done in a million way depending on how your enemies are programmed, choose one that fits your needs.

#### Nilsiboy

##### 1337 T045T
seems you are using another way of expanding, or i explained wrong...i make the ship expand by changing the graphic....works fine, even with the black/white, but you cant move...

#### saintdragon

##### Member
sorry very noob question...

how do i make a fpg, I THINK I HAVE THE RIGHT PROGRAM BUT I HAVE NO IDEA HOW I WOULD MAKE IT... help please.

probable been asked many times before but i have not yet found a answeer.

#### Quiest

##### I like turtles!
Have some bmps or pngs in a directory, start FPGEdit,click on new, change to that directory and just pull the bmps/pngs from the upper half of FPGEdit to the lower half.

And don`t forget to safe the FPG.

(btw, if you didn`t know, you can change the language to english, click on utilidades -> configurar FPGEdit -> Cambiar lenguaje del programa)

#### Moogle

##### .
These things should be in a FAQ

#### saintdragon

##### Member
Quiest posted on Apr 1 2005 at 06:20 AM said:
Have some bmps or pngs in a directory, start FPGEdit,click on new, change to that directory and just pull the bmps/pngs from the upper half of FPGEdit to the lower half.

And don`t forget to safe the FPG.

(btw, if you didn`t know, you can change the language to english, click on utilidades -> configurar FPGEdit -> Cambiar lenguaje del programa)

thanks alot but after 10 minutes of writting the post i found out how to make them, thanks for tring though.

i already had read how to make it english in a topic which i think you wrote and thanks alot alot fot that

Last edited by a moderator:

#### Quiest

##### I like turtles!
I was just told, that it`s possible to change the language in that topic

#### Nilsiboy

##### 1337 T045T
yeehaw solved my problem with moving...if only i had listened to you, replaced while with if four times....now it can move while expanding/returning to normal size, but it's choppy, as the graphic gets only changed once in this rather long loop. but i'll fix that

#### Nilsiboy

##### 1337 T045T
following piece of code has made *some* trouble.... i get a window that says :"Error in file "foobar" in line 95: Procedure name expected ("("))

Code:
``````if (BPushed==0)
if (COLLISION(type(bulletblack))
return;
END
END
if (BPushed==1)
if (COLLISION(type(bulletwhite))
return;
end
END``````

line 95 is the first return;

#### Moogle

##### .
If you replace the opening bracket between 'type' and bulletwhite/bulletblack with a space it oughta work.

#### Nilsiboy

##### 1337 T045T
it does
but got another problem -_-
it says ";" expected ("LOOP") ....but there IS a ";" at the end of the line

Replies
19
Views
4K
Replies
5
Views
2K
TelcoLou
T
Replies
5
Views
1K
Replies
1
Views
1K
Replies
7
Views
2K