seq::seq(int id, SUBDIV subdiv, int steps, SEQ_LOOP_TYPE loop, bool reverse) : _id(id), _stopped(true) { setchannel(Midi.midiChannel); setsubdiv(subdiv); setsteps(steps); setlooptype(loop); if(reverse) { setreverse(true); setposition(steps-1); } else { setreverse(false); setposition(0); } setbegin(0); if(steps <= MAX_STEPS) setend(steps-1); else setend(MAX_STEPS); for(int i = 0; i < MAX_STEPS; i++) { // _notes[i] = 36 + 3 * i; _notes[i] = 0; _velocity[i] = 127; } setinternal(true); setexternal(true); _lastposition = 0; }
MassiveParticle& MassiveParticle::operator=(MassiveParticle newpart){ setposition(newpart.m_position); setvelocity(newpart.m_velocity); setmass(newpart.m_mass); setke(); return *this; }
Drop::Drop(int32_t id, int32_t own, Point<int16_t> start, Point<int16_t> dst, int8_t type, int8_t mode, bool pldrp) : MapObject(id) { owner = own; setposition(start.x(), start.y() - 4); dest = dst; pickuptype = type; playerdrop = pldrp; opacity = 1.0f; moved = 0.0f; looter = nullptr; switch (mode) { case 0: case 1: state = DROPPED; basey = static_cast<double>(dest.y() - 4); phobj.vforce = -5.0f; phobj.hspeed = static_cast<double>(dest.x() - start.x()) / 48; break; case 2: state = FLOATING; basey = phobj.crnty(); phobj.setflag(PhysicsObject::NOGRAVITY); break; case 3: state = PICKEDUP; phobj.vforce = -5.0f; break; } }
int AGOSEngine_PN::actCallD(int n) { int pf[8]; funcentry(pf, n); addstack(kJmpClassNum); funccpy(pf); setposition(n, 0); return doline(1); }
void AGOSEngine_PN::opn_opcode22() { int pf[8]; int n = varval(); funcentry(pf, n); funccpy(pf); setposition(n, 0); setScriptReturn(true); }
void Mob::sendmovement(Point<int16_t> start, const Movement& movement) { if (control) return; setposition(start); lastmove = movement; uint8_t laststance = lastmove.newstate; setstance(laststance); phobj.fhid = lastmove.fh; }
/** * Prints the character to the console and moves cursor. Also accepts control characters! * TODO comment * * @param c character to print * @return the character printed */ int putchar(int c) { int position=getposition(); unsigned char ch=(unsigned char)c; if(position>=BUFFER_TEXT_WIDTH*BUFFER_TEXT_HEIGHT) { position=BUFFER_TEXT_WIDTH*(BUFFER_TEXT_HEIGHT-1); setposition(position); movelinesup(); } switch(ch) { case '\n': position+=BUFFER_TEXT_WIDTH-position%BUFFER_TEXT_WIDTH; break; case '\t': position+=5-position%5; break; case '\r': position-=position%BUFFER_TEXT_WIDTH; break; case '\b': position--; break; default: *(BUFFER_TEXT+position*2)=ch; *(BUFFER_TEXT+position*2+1)=getcolor(); position++; break; } setposition(position); return c; }
int main(void) { ALCdevice *dev; dev = alcOpenDevice( NULL ); if( dev == NULL ) { return 1; } context_id = alcCreateContext( dev, NULL); if(context_id == NULL) { alcCloseDevice( dev ); return 1; } alcMakeContextCurrent( context_id ); fixup_function_pointers(); setposition(-10.0, 10, 10); setposition(10.0, 10, 10); setposition(0.0, 10, 10); setposition(0.0, 0, 0); setorientation(0.0, 0, -1, 0, 1, 0); setorientation(0.0, 0, 1, 0, 1, 0); setorientation(0.0, 0, 1, 0, 1, 0); setposition(2, 2, 2); setorientation(0.0, 0, 1, 0, 1, 0); setposition(0, 0, 0); setorientation(0.0, 0, 1, 0, 1, 0); setposition(0, -10, 0); setorientation(1, 1, -1, 0, 1, 0); setposition(0, 0, 0); setorientation(0.0, 0, 1, 0, 1, 0); alcDestroyContext(context_id); alcCloseDevice( dev ); return 0; }
seq::seq(int id, SUBDIV subdiv, int steps, int channel) : _id(id), _stopped(true) { setchannel(channel); setsubdiv(subdiv); setsteps(steps); setlooptype(LOOP); setreverse(false); setposition(0); setbegin(0); if(steps <= MAX_STEPS) setend(steps-1); else setend(MAX_STEPS); for(int i = 0; i < MAX_STEPS; i++) { _notes[i] = 36 + 3 * i; _velocity[i] = 127; } setinternal(true); setexternal(true); _lastposition = 0; }
int8_t Drop::update(const Physics& physics) { physics.moveobject(phobj); if (state == DROPPED && phobj.onground) { phobj.hspeed = 0.0; phobj.setflag(PhysicsObject::NOGRAVITY); setposition(dest.x(), dest.y() - 4); state = FLOATING; } if (state == FLOATING) { phobj.y = basey + 5.0f + (cos(moved) - 1.0f) * 2.5f; moved = (moved < 360.0f) ? moved + 0.025f : 0.0f; } if (state == PICKEDUP) { static const uint16_t PICKUPTIME = 48; if (looter) { double hdelta = looter->x - phobj.x; phobj.hspeed = looter->hspeed / 2.0 + (hdelta - 16.0) / PICKUPTIME; } opacity -= 1.0f / PICKUPTIME; if (opacity <= 1.0f / PICKUPTIME) { opacity = 0.0f; MapObject::deactivate(); return -1; } } return phobj.fhlayer; }
void AGOSEngine_PN::opn_opcode21() { setposition(_procnum, varval()); setScriptReturn(true); }
void MapObject::setposition(Point<int16_t> position) { int16_t x = position.x(); int16_t y = position.y(); setposition(x, y); }
Mob::Mob(int32_t oi, int32_t mid, int8_t mode, int8_t st, uint16_t fh, bool newspawn, int8_t tm, Point<int16_t> position) : MapObject(oi) { std::string strid = string_format::extend_id(mid, 7); nl::node src = nl::nx::mob[strid + ".img"]; nl::node info = src["info"]; level = info["level"]; watk = info["PADamage"]; matk = info["MADamage"]; wdef = info["PDDamage"]; mdef = info["MDDamage"]; accuracy = info["acc"]; avoid = info["eva"]; knockback = info["pushed"]; speed = info["speed"]; flyspeed = info["flySpeed"]; touchdamage = info["bodyAttack"].get_bool(); undead = info["undead"].get_bool(); noflip = info["noFlip"].get_bool(); notattack = info["notAttack"].get_bool(); canjump = src["jump"].size() > 0; canfly = src["fly"].size() > 0; canmove = src["move"].size() > 0 || canfly; if (canfly) { animations[STAND] = src["fly"]; animations[MOVE] = src["fly"]; } else { animations[STAND] = src["stand"]; animations[MOVE] = src["move"]; } animations[JUMP] = src["jump"]; animations[HIT] = src["hit1"]; animations[DIE] = src["die1"]; name = nl::nx::string["Mob.img"][std::to_string(mid)]["name"]; nl::node sndsrc = nl::nx::sound["Mob.img"][strid]; hitsound = sndsrc["Damage"]; diesound = sndsrc["Die"]; speed += 100; speed *= 0.001f; flyspeed += 100; flyspeed *= 0.0005f; if (canfly) phobj.type = PhysicsObject::FLYING; id = mid; team = tm; setposition(position); setcontrol(mode); phobj.fhid = fh; phobj.setflag(PhysicsObject::TURNATEDGES); hppercent = 0; dying = false; dead = false; fading = false; awaitdeath = false; setstance(st); flydirection = STRAIGHT; counter = 0; namelabel = Text(Text::A13M, Text::CENTER, Text::WHITE); namelabel.setback(Text::NAMETAG); namelabel.settext(name); if (newspawn) { fadein = true; opacity.set(0.0f); } else { fadein = false; opacity.set(1.0f); } if (control && stance == Stance::STAND) { nextmove(); } }
int main (void) { int i, l, x, y, xc, gd, gm; char s[32]; gd = X11; gm = X11_1024x768; initgraph (&gd, &gm, ""); setbkcolor (BLACK); /* Koch */ for (i = 0; i < 6; i++) { cleardevice (); setcolor (GREEN); outtextxy (0, 0, "Standard Koch curve:"); setposition (0, getmaxy () / 2); setheading (T_EAST); setcolor (i + 1); koch (getmaxx () + 1, i); usleep (500000); } setcolor (YELLOW); outtextxy (0, 20, "PRESS A KEY TO CONTINUE:"); getch (); /* fractal tree */ for (i = 0; i < 14; i++) { cleardevice (); setcolor (YELLOW); outtextxy (0, 0, "Tree:"); setposition (getmaxx () *4/10, getmaxy ()); setheading (T_NORTH); tree (getmaxy () / 3, i); usleep (500000); } setcolor (YELLOW); outtextxy (0, 20, "PRESS A KEY TO CONTINUE:"); getch (); /* square Koch */ for (i = 0; i < 6; i++) { cleardevice (); setcolor (RED); outtextxy (0, 0, "Square Koch curve:"); setposition (0, getmaxy () / 2); setheading (T_EAST); setcolor (i + 1); sq_koch (getmaxx () + 1, i); usleep (500000); } setcolor (YELLOW); outtextxy (0, 20, "PRESS A KEY TO CONTINUE:"); getch (); /* rotating square */ cleardevice (); setcolor (RED); outtextxy (0, 0, "Rotating square:"); home (); setheading (0); l = getmaxx () / 2; for (i = 1; i < l; i++) { setcolor (1 + i % 15); forwd (i); turnright (89); delay (10); if (kbhit ()) break; } setcolor (YELLOW); outtextxy (0, 20, "PRESS A KEY TO CONTINUE:"); getch (); /* Hilbert */ setbkcolor (WHITE); cleardevice (); xc = getmaxx () / 2; x = xc; for (i = 1; i < 8; i++) { l = getmaxy () / powerof2 (i); x += l / 2; y = l / 2; setposition (x, y); setheading (T_WEST); setcolor (BLUE); hilbert_left (l, i); sprintf (s, "Hilbert curve at level %d", i); setcolor (BLUE); outtextxy (0, 0, s); getch (); cleardevice (); } outtextxy (0, 0, "PRESS A KEY TO EXIT:"); /* stars */ while (! kbhit ()) { setposition (random (getmaxx ()), random (getmaxy ())); setheading (random (360)); setcolor (1 + random (15)); star (random (80)); star_6 (random (20)); star_20 (random (40)); usleep (50000); } closegraph (); return (0); }