Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- EntityBase2D.bs ---
- public class EntityBase2D {
- public vec2f origin;
- public float angle;
- public float radius;
- public string sprite;
- public vec2f sprite_sz;
- /** called after entity creation */
- public abstract void spawn();
- public abstract void tick();
- public abstract void touch(EntityBase2D other);
- public abstract void use(EntityBase2D other);
- }
- --- NpcDialogBox.bs ---
- public native void IsoTest_SetDialog(NpcDialogBox dbox);
- public class NpcDialogBox {
- /** first frame of face sprite */
- public string face1;
- /** second frame of face sprite */
- public string face2;
- /** text for dialog box */
- public string text;
- public string[] options;
- public NpcDialogBox[] optchain;
- public void impulse(int imp)
- {
- frgl_printf("Diag Impulse %d\n", imp);
- if((imp>0) && optchain)
- {
- IsoTest_SetDialog(optchain[imp-1]);
- }
- }
- }
- --- IsoMain.bs ---
- native int frgl_printf(cstring str, ...);
- native int clock();
- native int rand();
- public EntityBase2D[] world_entity;
- public int world_max_entity;
- public class misc_chest extends EntityBase2D {
- int isOpen;
- public void spawn()
- {
- sprite_sz=#[32, 32];
- radius=8;
- if(rand()&1)
- {
- isOpen=0;
- sprite="sprites/isotest/chest_closed";
- }else
- {
- isOpen=1;
- sprite="sprites/isotest/chest_open";
- }
- }
- public void tick()
- {
- }
- public void touch(EntityBase2D other)
- {
- }
- public void use(EntityBase2D other)
- {
- // isOpen=!isOpen;
- if(isOpen)
- {
- sprite="sprites/isotest/chest_closed";
- isOpen=0;
- return;
- }
- sprite="sprites/isotest/chest_open";
- isOpen=1;
- }
- }
- public class player extends EntityBase2D {
- public void spawn()
- {
- sprite_sz=#[32, 48];
- radius=8;
- }
- public void tick()
- {
- }
- public void touch(EntityBase2D other)
- {
- }
- public void use(EntityBase2D other)
- {
- }
- }
- public class npc_elf extends EntityBase2D {
- static NpcDialogBox diag0, diag1, diag2;
- static bool isInit=false;
- public static void init()
- {
- if(isInit)
- return;
- isInit=true;
- frgl_printf("Elf Init\n");
- diag0=new NpcDialogBox;
- diag1=new NpcDialogBox;
- diag2=new NpcDialogBox;
- diag0.face1="sprites/elf/elfface0_happy0";
- diag0.face2="sprites/elf/elfface0_cheer0";
- diag0.text=
- """
- Greetings! I am an Elf.
- Elves are a common resident here.
- """;
- diag0.options=[
- "Ask about elves.",
- "Ask about goats.",
- "Goodbye."];
- diag0.optchain=[null, diag1, diag2, null, null, null];
- diag1.face1="sprites/elf/elfface0_happy0";
- diag1.face2="sprites/elf/elfface0_cheer0";
- diag1.text=
- """
- Elves are a common resident here.
- Here, being, of course, the polar region.
- The polar region is a space 'inside' of what you think of as
- the North and South poles.
- In effect, an alternate Earth which occupies the same physical space.
- """;
- diag1.options=["Return."];
- diag1.optchain=[diag0, diag0, null, null, null];
- diag2.face1="sprites/elf/elfface0_unhappy0";
- diag2.face2="sprites/elf/elfface0_shock0";
- diag2.text=
- """
- Why do you ask about goats?
- We must never speak of goats!
- """;
- diag2.options=["Return."];
- diag2.optchain=[diag0, diag0, null, null, null];
- }
- public void spawn()
- {
- init();
- sprite_sz=#[32, 64];
- radius=8;
- sprite="sprites/elf/elf0_1";
- }
- public void tick()
- {
- }
- public void touch(EntityBase2D other)
- {
- }
- public void use(EntityBase2D other)
- {
- IsoTest_SetDialog(diag0);
- // sprite="sprites/isotest/chest_open";
- // isOpen=1;
- }
- }
- double accDt;
- public void update(double dt)
- {
- int i;
- accDt=accDt+dt;
- if(accDt<0.04)
- return;
- accDt-=0.04;
- for(i=0; i<world_max_entity; i++)
- {
- world_entity[i].tick();
- }
- }
- public int main(string[] args)
- {
- frgl_printf("IsoMain\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement