Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
need some help on a program #323031
05/11/10 01:50
05/11/10 01:50
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
Hey, a group of friends and me have been trying to program a simple 2d game for a school. I am making the program that will create the bullet at the players location...Problem is, I have been trying to write this code for a few weeks and i keep getting stuck on how to create input the players x_position for where the bullet should be created on the x-axis...if anyone could lend a hand I would be very happy =D.

As you can see when you run the program, the engine will state the value of 'v' before and after creating the bullet, and they will have that value at the correct number...however the engine will only create the bullet at x_position 0

Quote:
#include <acknex.h>
int v;
var player_score = 0;

PANEL* main_char=
{
bmap = "player.bmp"; //this is where you write the name of the picture you want for the main character
layer = 11;
pos_x = 0; // x position for the char
pos_y = 100; // y position for the char
flags = SHOW | OVERLAY;
}

function update_player(PANEL *paddle,var paddle_mode,var key) //this function updates the player
{
{

paddle.pos_x += 30*time_step*key;
paddle.pos_x = clamp(paddle.pos_x,0,700);
v = paddle.pos_x;
//printf("%d", v);
}

}

#define USER 1

var mode_player = USER;

BMAP *mybullet = "missile.bmp";

void run_bullet()
{

printf("%d", v);
PANEL *mypanel = pan_create( "bmap=mybullet; flags=VISIBLE | OVERLAY; pos_y = 130; pos_x = v;", 11);
printf("%d", v);



while( mypanel->pos_y < screen_size.y )
{
mypanel->pos_y += 15 * time_step;
wait(1);
}

}

function main ()
{
//int v;
int enemy_count;

while (enemy_count != 15)
{
update_player(main_char, mode_player, key_d-key_a); // makes d and a the keys to be pressed in order to move the player
wait (1);
if (key_v)
{
run_bullet();
enemy_count++; //
wait (200);
}
}

}



thanks for any help given!
DG


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com
Re: need some help on a program [Re: Doof_Guy] #323032
05/11/10 03:17
05/11/10 03:17
Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
Captain_Kiyaku Offline

Dichotomic
Captain_Kiyaku  Offline

Dichotomic

Joined: Apr 2002
Posts: 4,801
Richmond B.C., Canada
I didn't use 3dgs for years but what does your

printf("%d", v);

say?

Don't you have the variable "v" as a string to the panel string instead of writing it as char into the string? I guess it just interpret it as the char "v" which won't work and deliver 0?

I dunno how you can combine strings now in 3dgs but it's probably supposed to be something like this:

PANEL *mypanel = pan_create( "bmap=mybullet; flags=VISIBLE | OVERLAY; pos_y = 130; pos_x = " + v + ";", 11);


My Blog

"Tag und Nacht schrei ich mich heiser,
Wind weht alle Worte fort,
Tag und Nacht schrei ich mein Krähenwort!"

Subway To Sally - Krähenkönig
Re: need some help on a program [Re: Captain_Kiyaku] #323046
05/11/10 11:22
05/11/10 11:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
PANEL *mypanel = pan_create( "bmap=mybullet; flags=VISIBLE | OVERLAY; pos_y = 130; pos_x = v;", 11);

This won't work. Try this instead:

PANEL *mypanel = pan_create( "bmap=mybullet; flags=VISIBLE | OVERLAY; pos_y = 130;", 11);
mypanel.pos_x = v;


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: need some help on a program [Re: Superku] #323099
05/11/10 16:37
05/11/10 16:37
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
don't you have to typecast?
printf("%d", (double)v);


~"I never let school interfere with my education"~
-Mark Twain
Re: need some help on a program [Re: Germanunkol] #323139
05/11/10 19:45
05/11/10 19:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
No, v is of type int.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: need some help on a program [Re: Superku] #323157
05/11/10 21:00
05/11/10 21:00
Joined: Sep 2007
Posts: 268
United States
Doof_Guy Offline OP
Member
Doof_Guy  Offline OP
Member

Joined: Sep 2007
Posts: 268
United States
Thanks everyone for your fast responses!

Superku's solution worked right away! xD

DG


To see what 3d models i have made and animated, see the link to my bloghttp://championsdawn.blogspot.com

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1