Fenix Code Help


Moogle

.
Joined
Apr 27, 2004
Messages
283
Age
36
Location
Netherlands
Website
Visit site
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 ;).
 

Moogle

.
Joined
Apr 27, 2004
Messages
283
Age
36
Location
Netherlands
Website
Visit site
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;
radius = 10;

BEGIN

set_mode(m320x240);

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

loop
  advance(speedo);

  if(x>(320-radius) or x<(0+radius))
    angle = -angle + 180000;
  end
  
  if(y>(240-radius) or y<(0+radius))
    angle = -angle;
  end

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

END
 

Sonic-NKT

Very Active Member
Joined
Apr 15, 2003
Messages
1,890
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
Joined
Jul 9, 2003
Messages
489
Age
45
Location
The North
Website
www.deardenboys.co.uk
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;
radius = 10;

BEGIN

set_mode(m320x240);

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

loop
  advance(speedo);

  if(x>(320-radius) or x<(0+radius))
    angle = -angle + 180000;
  end
  
  if(y>(240-radius) or y<(0+radius))
    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
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
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
Joined
Feb 11, 2005
Messages
967
Age
30
Location
LONDON
Website
Visit site
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.

thanks in advance
 

Moogle

.
Joined
Apr 27, 2004
Messages
283
Age
36
Location
Netherlands
Website
Visit site
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
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
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

.
Joined
Apr 27, 2004
Messages
283
Age
36
Location
Netherlands
Website
Visit site
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
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
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
Joined
Feb 11, 2005
Messages
967
Age
30
Location
LONDON
Website
Visit site
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!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
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)
 

saintdragon

Member
Joined
Feb 11, 2005
Messages
967
Age
30
Location
LONDON
Website
Visit site
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:

Nilsiboy

1337 T045T
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
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
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
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;
please help me, I tried several things (probably useless dumb things) but it didnt work <_<
 

Nilsiboy

1337 T045T
Joined
Jul 9, 2004
Messages
561
Age
31
Website
Visit site
it does :)
but got another problem -_-
it says ";" expected ("LOOP") ....but there IS a ";" at the end of the line :(
 
Top