Sorry guys I had a crazy month (I think the other people in my game project have probably hired bounty hunters to get me by now). I'll check out my code and the state of the pull, as well as CW's comment asap.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
//in the function:
...
else if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hQuit){
object[0].Visible = false;
object[1].Visible = false;
object[2].Visible = true;}
object[2].TweenY(2.0, object[2].Y - 10, eEaseLinearTween, eReverseRepeatTween); //the important line
object[2].StopTweenPosition();
Quote from: SinSin on Tue 25/09/2018 16:12:34
Ok thanks very much for the replies guys. I won't be using the variable in question too many times. It's mainly for a shop, I'll just work some if statements into to function to check whether the player has enough money to make a purchase.
Handy to know though. Thanks again.
int playerFortune = 100;
struct ObjectToPurchase {
int price;
import bool CanBePurchased();
}
ObjectToPurchase objectsForSale[10];
bool ObjectToPurchase::CanBePurchased() {
return (playerFortune - this.price > 0);
}
//player tried to buy object #6
if (!objectsforSale[6].CanBePurchased()) {
player.say("That trumpet is too expensive.");
}
Quote from: Duckbutcher on Thu 20/09/2018 16:17:09
Error is '.angle' is not a public member of 'ProjectileStruct'.
struct ProjectileStruct
{
...
float angleInRadians;
}
Quote from: Slasher on Fri 21/09/2018 13:40:56
How universal is 7Zip regarding people being able to open and extract a game?
Quote from: artium on Wed 19/09/2018 19:02:25
It is hosted on Github: https://github.com/alkhimey/HintsHighlight
Quote from: cat on Thu 13/09/2018 19:06:37Because linuxians. They like to capture the souls of innocent passerbys and torture them until they have entirely drained the will to live from them. They take a specific perverted pleasure in doing so by providing tools meant for Windows but made on Linux and yet not compiled for Windows.
Why on earth can't they just provide a Windows installer?
Quote from: Mandle on Mon 17/09/2018 23:45:26Oh yeah, I didn't notice the necropostingQuote from: Monsieur OUXX on Mon 17/09/2018 18:08:44
No one even mentionned Chronicles of Innsmouth, made with AGS!
Most of these posts are from 2016.
#define MAX_PROJECTILES 6 //if you want to be able to fire repeatedly
#define COOLDOWN 30 //we allow the player to shoot once every 30 frames, which is approximately 500ms at 60FPS
#define PROJECTILE_SPEED 1.0 //how much the projectile moves during each frame
#define PROJECTILE_LIFESPAN 240 //A projectile can live up to 240 game cycles, which is 4 seconds at 60FPS
struct ProjectileStruct {
bool inUse;
Character* c;
float x; //coordinates in float to free ourselves from moving the projectiles at speeds that must match exactly screen pixels
float y;
float angleInRadians; //Reminder : 360 degrees = 2*Pi
int age; //how many game cycles have elapsed since it was created
};
ProjectileStruct projectiles[MAX_PROJECTILES];
int coolDown;
void MakeProjectile(int p)
{
projectiles[p].inUse = true;
int direction = -1;
float angle = 0.0;
int xOffset = 0; int yOffset = 0;
switch (player.Loop){
case 0 :
direction = eDirectionDown; xOffset = 0; yOffset = 50; angle = 3.0*Maths.Pi/2.0; // (3/2)Pi = 270 degrees = down
break;
case 1 :
direction = eDirectionLeft; xOffset = -50; yOffset = 0; angle = 2.0*Maths.Pi; // 2Pi = 180 degrees = left
break;
case 2 :
direction = eDirectionRight; xOffset = 50; yOffset = 0; angle = 0.0; // 0 = 0 degrees = right
break;
case 3 :
direction = eDirectionUp; xOffset = -50; yOffset = 0; angle = Maths.Pi/2.0; // Pi/2 = 90 degrees = up
break;
}
projectiles[p].c.Visible = true;
projectiles[p].c.Move(cego.x+xOffset, cego.y+yOffset, eNoBlock, eAnywhere);
projectiles[p].c.FaceDirection(direction);
projectiles[p].x = IntToFloat(projectiles[p].c.x);
projectiles[p].y = IntToFloat(projectiles[p].c.y);
projectiles[p].age = 0;
}
//Update projectiles location at each screen refresh
void MoveProjectiles()
{
for (int p=0; p<MAX_PROJECTILES; p++) {
if(projectiles[p].inUse) { //in use
//Our accurate locations, in float
projectiles[p].x+=Maths.Cos(projectiles[p].angle)*PROJECTILE_SPEED;
projectiles[p].y+=Maths.Sin(projectiles[p].angle)*PROJECTILE_SPEED;
//Our on-screen locations, in pixels (rounded from the float value)
projectiles[p].c.x = FloatToInt(projectiles[p].x);
projectiles[p].c.y = FloatToInt(projectiles[p].y);
}
}
}
//Kill projectiles that have been around for too long
void KillProjectiles()
{
for (int p=0; p<MAX_PROJECTILES; p++) {
if (projectiles[p].inUse) {
projectiles[p].age++;
if (projectiles[p].age > PROJECTILE_LIFESPAN) {
projectiles[p].inUse = false;
projectiles[p].c.Visible = false;
projectiles[p].age = 0;
}
}
}
}
void ManageShooting()
{
if (IsKeyPressed(eKeySpace)) {
if(coolDown==0) {
coolDown = COOLDOWN; //reset cooldown
//Find a projectile that's not in use
for (int i=0; i<MAX_PROJECTILES; i++) {
if(!projectiles[i].inUse) { //found!
MakeProjectile(i);
break; //stop looking immediately
}
}
}
}
}
void repeatedly_execute()
{
if (coolDown > 0)
coolDown--;
ManageShooting();
MoveProjectiles();
KillProjectiles();
}
//Bind your in-game projectiles with some actual characters from your game, that you created in the editor
void InitProjectiles()
{
projectiles[0].c = cFire0;
projectiles[1].c = cFire1;
projectiles[2].c = cFire2;
projectiles[3].c = cFire3;
projectiles[4].c = cFire4;
projectiles[5].c = cFire5;
}
void game_start()
{
SetGameSpeed(60); //600FPS is probably better than AGS' weird native 40FPS
InitProjectiles();
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.266 seconds with 16 queries.