Author Topic: ※ Danmakufu Q&A/Problem thread 3 ※  (Read 481002 times)

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1440 on: July 19, 2018, 12:28:01 PM »
Hmm... How about... a detail of implementing a code that consists a black hole that sucks/pulls the player towards it (like Utsuho/Okuu's "Artificial Sun")?
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1441 on: July 19, 2018, 05:01:55 PM »
That's pretty easy, actually. You just need a task that looks something like this.

Code: [Select]
task gravity(){
    while(!Obj_IsDeleted(bossObj)){
        ObjMove_SetPosition(GetPlayerObjectID,GetPlayerX+cos(GetAngleToPlayer(bossObj)+180),GetPlayerY+sin(GetAngleToPlayer(bossObj)+180));
        wait(2) //wait(1) might also work
    }
}

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1442 on: July 21, 2018, 07:17:04 AM »
That is one way to do it, except it lacks the control over the strength of the 'gravitational pull'. Here is a snippet from my own game which is based on 'strength' (velocity)

Code: [Select]
while(!Obj_IsDeleted(bossObj)) {
x = GetPlayerX;
y = GetPlayerY;

dir = GetPointToPointAngle(GetEnemyX, GetEnemyY, GetPlayerX, GetPlayerY);
ObjMove_SetAngle(locPlayerID, dir);
vx = v * cos(dir);
vy = v * sin(dir);

ObjRender_SetPosition(locPlayerID, x + vx, y + vy, 0);

yield;
}

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1443 on: July 24, 2018, 06:25:20 PM »
I'm trying to make bullets that bounce off the wall once and then go throught players position (boss shoots at the wall, bullet reflects to the position player was at the moment that bullet was shot) but I'm having trouble calculating the initial angle for the bullet. Can anyone help with this?

R. P. Genocraft

  • Craftsman of absolute unpredictability
  • Boundary of productive and lazy
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1444 on: July 24, 2018, 08:56:30 PM »
I'm trying to make bullets that bounce off the wall once and then go throught players position (boss shoots at the wall, bullet reflects to the position player was at the moment that bullet was shot) but I'm having trouble calculating the initial angle for the bullet. Can anyone help with this?
Store the player's X and Y position at the moment the bullet is fired, when it hits the wall calculate the angle between the bullet and said position: let angle= atan2(Y2-Y1,X2-X1); X2 and Y2 being the player's stored position, X1 and Y1 the bullet's current position.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1445 on: July 25, 2018, 12:54:05 AM »
The above is a sensible approach, I'm just wondering why phrase it as though you need an initial angle for the bullets. If the method you would be using to reflect the bullets is a static change in angle, then there is only one possible initial angle to shoot at for a given player position and wall.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1446 on: July 25, 2018, 05:52:44 AM »
Well, I'm not that good at english, so i probably didn't explain properly. ObjMove_SetAngle(obj, (180 - ObjMove_GetAngle(obj))); this is a formula that i use to reflect the bullets off the right and left walls. I want a bullet to reflect using that formula, but still hit the player. The problem is calculating an angle which boss has to shoot at.

But I actualy figured it out already, so nvm. Still, thanks for the help.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1447 on: August 06, 2018, 12:45:32 AM »
Hello, I'm currently working on stages but I'm having a problem with hitboxes.

When I try to get the position of an enemy sprite i created, the playing field is used as referential, which means that  (0, 0) is located at (32,16) on the full game screen (see SetStgFrame() default parameters).
So to get my rect hitbox right, i need to shift it by (-32,-16) in order to be centered with the rendered sprite.

I'm using a function as a fix for the moment but i'd like to know if there is way to make sure the same referential is used everywhere : full game screen or playing field only.

« Last Edit: August 06, 2018, 12:48:27 AM by tkon »

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1448 on: August 06, 2018, 08:37:03 AM »
The thing is that it's done like that as a convenience for the programmer, as you probably shouldn't be doing game-relevant stuff in a context where (0, 0) is the origin, and shouldn't be doing non-game-relevant stuff in the context where (32, 16) is. There's probably an issue with how you're attempting to tackle a problem that's making this more complicated than it should be.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1449 on: August 06, 2018, 10:01:13 AM »
The thing is I'm setting the hitbox position just after setting the sprite position :

Code: [Select]
ObjSprite2D_SetDestCenter(objEnemy);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 8);

Both functions use a different referential and i don't get why it is actually the case.
Maybe I'm using the wrong function to set it up. The radius has an effect ?

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1450 on: August 06, 2018, 10:17:56 AM »
Hi,

Is there a way to change the length of a loose laser while it is moving, such that it becomes shorter?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1451 on: August 06, 2018, 01:03:57 PM »
Hi,

Is there a way to change the length of a loose laser while it is moving, such that it becomes shorter?

There's ObjLaser_SetLength but you'll need to experiment a bit since I think it will shrink from the tip towards the base.

Drake

  • *
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1452 on: August 06, 2018, 10:21:27 PM »
The thing is I'm setting the hitbox position just after setting the sprite position :

Code: [Select]
ObjSprite2D_SetDestCenter(objEnemy);
ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 32);
ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 8);

Both functions use a different referential and i don't get why it is actually the case.
Maybe I'm using the wrong function to set it up. The radius has an effect ?
Yes, but I'm saying that your sprite shouldn't be centered at (0, 0) of the whole window under normal circumstances. The most common reason you'd have this is if you were drawing the enemy at a render priority considered outside the bounds of gameplay, i.e. outside the range 20~80.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1453 on: August 07, 2018, 11:21:32 AM »
There's ObjLaser_SetLength but you'll need to experiment a bit since I think it will shrink from the tip towards the base.

When I tried this before, it essentially had no visual effect. Both the sprite and the hitbox don't seem to get any shorter, or at least not at the rate that I intended.
I've sidestepped the problem by manually moving a straight laser with the same graphic and dimensions. Nonetheless, it would be nice to know how to implement it with a loose laser for future reference.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1454 on: August 11, 2018, 10:32:36 AM »
Yes, but I'm saying that your sprite shouldn't be centered at (0, 0) of the whole window under normal circumstances. The most common reason you'd have this is if you were drawing the enemy at a render priority considered outside the bounds of gameplay, i.e. outside the range 20~80.

Thanks, you're right it fixed it. I increased priority to keep track of mobs after they leave the screen.

I'm wondering, is there a way to reduce frame drop ? When i call the mid boss, in the middle of my stage, FPS tends to halve for few frames before coming back to normal.  Is there a way to preload the boss/mobs to reduce this effect ?

Code: [Select]
task TStage
{
    let dir = GetCurrentScriptDirectory();
    let path = dir ~ "Stage 1/Plural_midBoss.dnh";
    let idScript = LoadScriptInThread(path);
    .
    . my stage
    .
    StartScript(idScript);
    while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
    {
        yield;
    }

    .
    . my stage again
    .

    CloseStgScene();
}

HumanReploidJP

  • The Scripter with Something of Common Sense
  • "Start the life of an idol! Let's get STAR~ted!"
    • HumanReploidJP's Youtube Channel
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1455 on: August 13, 2018, 02:11:43 PM »
Thinking about the spinning straight lasers, I wonder if there's a code that the rotation of a spinning laser is decelerated to 0 (like Yuyuko lasers during the final spell: https://youtu.be/PuU9Rxi_vyY?t=8) before it fires... If  there's one solution, then let me know.
MiraikeiBudoukan (Futuristic Vineyard) Game Concepts (WIP)
(Non-Touhou, yet bullet-hell-Inspirable (Like JynX). Don't get serious.)

Gregory

  • I draw stuffs
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1456 on: August 14, 2018, 06:38:43 AM »
Thinking about the spinning straight lasers, I wonder if there's a code that the rotation of a spinning laser is decelerated to 0 (like Yuyuko lasers during the final spell: https://youtu.be/PuU9Rxi_vyY?t=8) before it fires... If  there's one solution, then let me know.

Non-directional laser can be spined by using ObjMove_SetPosition around of the boss
For example:
Code: [Select]
ObjMove_SetPosition(obj, ObjMove_GetX(BossObj)+r*cos(ang),ObjMove_GetY(BossObj)+r*sin(ang),ang);
ObjStLaser_SetAngle(obj, numofhowmanylasertobespined);

Kinedyme

  • Dream Magic - Duplex Spark!
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1457 on: August 14, 2018, 12:55:30 PM »
I'm trying to recreate the movement of ObjMove_SetDestAtWeight(); I am using a task that sets the position of the object every frame until it reaches its destination, but I'm having trouble with one part.

It seems that the original command cancels the movement if another ObjMove operation is applied to the object in question. How can I implement this feature?

JDude :3

  • tururu
  • boy with code
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1458 on: August 19, 2018, 11:40:35 PM »
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)
"dnh is hard" - said no one
"dnh is bullshit" - everyone making a creative pattern

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1459 on: August 20, 2018, 02:16:41 AM »
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)

I recommend using CommonData. Refer to https://sparen.github.io/ph3tutorials/ph3u3l24.html

CrestedPeak9

  • Fangame Advocate
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1460 on: August 20, 2018, 04:34:12 AM »
How can I make difficulties like Easy, Normal, Hard and Lunatic? (without having to make 4 plurals, since it takes too much space and time?)

Aside from Sparen's suggestion, I'd also advice you look at how Danmakufu fangames utilize common data to simplify difficulty implementation; I personally like BoSM's pattern difficulty which is coded with arrays containing data for bullet speed, types, shot ways, etc.
Lunatic 1cc: EoSD, PCB, IN, MoF, TD, DDC, LoLK, HSiFS, WBaWC

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1461 on: August 22, 2018, 06:46:31 PM »
I have been wondering how you make aimed player shots (as in, CreatePlayerShotA1(blabla)), I have some kind of idea with GetEnemyBossObjID() (and similar) but I dont think that is enough, and I tried some stuff, it didn't work, does anybody know how to make them?


Edit: nvm I made it
« Last Edit: August 22, 2018, 10:12:33 PM by WelshRabbit »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1462 on: August 26, 2018, 02:15:02 AM »
Hi, how can I do the humming sound when hitting a boss?

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1463 on: August 26, 2018, 03:19:22 AM »
Hi, how can I do the humming sound when hitting a boss?

The boss can run a loop that keeps track of HP. If HP changes during a frame, then play the sound effect.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1464 on: August 26, 2018, 02:47:46 PM »
How can I do this effect?(the green aura)

(image taken from the kirbio's Range 15 script, Koishitale)

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1465 on: August 26, 2018, 04:37:31 PM »
How can I increase playing field's size using camera zoom without changing STG frame?
« Last Edit: August 26, 2018, 05:40:14 PM by Alex Renz »

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1466 on: August 26, 2018, 04:56:18 PM »
Basically you have a task that constantly creates coloured copies of the boss sprite and then enlarges their scale and lowers their alpha, deleting them when the alpha lowers below zero. You might need to mess around with blend types a little to make the aura look nice.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1467 on: August 26, 2018, 05:49:22 PM »
Basically you have a task that constantly creates coloured copies of the boss sprite and then enlarges their scale and lowers their alpha, deleting them when the alpha lowers below zero. You might need to mess around with blend types a little to make the aura look nice.
Wouldn't it cause some good amount of lag?
« Last Edit: August 26, 2018, 07:04:46 PM by Zinochan »

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1468 on: August 26, 2018, 06:26:30 PM »
Wouldn't it cause some good amount of lag?

Depends on how many are in existence at any given time as well as other factors. Make sure that you test our your implementation on a proper attack so you can see what the FPS will be *with* bullets and other effects.

Re: ※ Danmakufu Q&A/Problem thread 3 ※
« Reply #1469 on: August 26, 2018, 07:04:56 PM »
And which function can I use to make the alpha of the boss texture white? (I mean to make the boss all white, but with the opacity)