com.badlogic.gdx.utils.FloatArray Java Examples
The following examples show how to use
com.badlogic.gdx.utils.FloatArray.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrooveGauge.java From beatoraja with GNU General Public License v3.0 | 5 votes |
public static GrooveGauge create(BMSModel model, int type, PlayerResource resource) { int coursetype = 0; GaugeProperty gauges = null; if(resource.getCourseBMSModels() != null){ coursetype = 1; for (CourseData.CourseDataConstraint i : resource.getConstraint()) { switch(i) { case GAUGE_5KEYS: gauges = GaugeProperty.FIVEKEYS; break; case GAUGE_7KEYS: gauges = GaugeProperty.SEVENKEYS; break; case GAUGE_9KEYS: gauges = GaugeProperty.PMS; break; case GAUGE_24KEYS: gauges = GaugeProperty.KEYBOARD; break; case GAUGE_LR2: gauges = GaugeProperty.LR2; break; default: break; } } } GrooveGauge gauge = create(model, type, coursetype, gauges); FloatArray[] f = resource.getGauge(); if (f != null) { for(int i = 0; i < f.length; i++) { gauge.setValue(i, f[i].get(f[i].size - 1)); } } return gauge; }
Example #2
Source File: ChainLight.java From box2dlights with Apache License 2.0 | 5 votes |
/** * Creates chain light from specified vertices * * @param rayHandler * not {@code null} instance of RayHandler * @param rays * number of rays - more rays make light to look more realistic * but will decrease performance, can't be less than MIN_RAYS * @param color * color, set to {@code null} to use the default color * @param distance * distance of light * @param rayDirection * direction of rays * <ul> * <li>1 = left</li> * <li>-1 = right</li> * </ul> * @param chain * float array of (x, y) vertices from which rays will be * evenly distributed */ public ChainLight(RayHandler rayHandler, int rays, Color color, float distance, int rayDirection, float[] chain) { super(rayHandler, rays, color, distance, 0f); rayStartOffset = ChainLight.defaultRayStartOffset; this.rayDirection = rayDirection; vertexNum = (vertexNum - 1) * 2; endX = new float[rays]; endY = new float[rays]; startX = new float[rays]; startY = new float[rays]; this.chain = (chain != null) ? new FloatArray(chain) : new FloatArray(); lightMesh = new Mesh( VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); softShadowMesh = new Mesh( VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); setMesh(); }
Example #3
Source File: ChainLight.java From box2dlights with Apache License 2.0 | 5 votes |
/** * Draws a polygon, using ray start and end points as vertices */ public void debugRender(ShapeRenderer shapeRenderer) { shapeRenderer.setColor(Color.YELLOW); FloatArray vertices = Pools.obtain(FloatArray.class); vertices.clear(); for (int i = 0; i < rayNum; i++) { vertices.addAll(mx[i], my[i]); } for (int i = rayNum - 1; i > -1; i--) { vertices.addAll(startX[i], startY[i]); } shapeRenderer.polygon(vertices.shrink()); Pools.free(vertices); }
Example #4
Source File: ChainLight.java From box2dlights with Apache License 2.0 | 5 votes |
@Override public boolean contains(float x, float y) { // fast fail if (!this.chainLightBounds.contains(x, y)) return false; // actual check FloatArray vertices = Pools.obtain(FloatArray.class); vertices.clear(); for (int i = 0; i < rayNum; i++) { vertices.addAll(mx[i], my[i]); } for (int i = rayNum - 1; i > -1; i--) { vertices.addAll(startX[i], startY[i]); } int intersects = 0; for (int i = 0; i < vertices.size; i += 2) { float x1 = vertices.items[i]; float y1 = vertices.items[i + 1]; float x2 = vertices.items[(i + 2) % vertices.size]; float y2 = vertices.items[(i + 3) % vertices.size]; if (((y1 <= y && y < y2) || (y2 <= y && y < y1)) && x < ((x2 - x1) / (y2 - y1) * (y - y1) + x1)) intersects++; } boolean result = (intersects & 1) == 1; Pools.free(vertices); return result; }
Example #5
Source File: PathDrawer.java From shapedrawer with MIT License | 4 votes |
void path (FloatArray userPath, float lineWidth, JoinType joinType, boolean open) { path (userPath.items, 0, userPath.size, lineWidth, joinType, open); }
Example #6
Source File: SkinGauge.java From beatoraja with GNU General Public License v3.0 | 4 votes |
@Override public void prepare(long time, MainState state) { super.prepare(time, state); GrooveGauge gauge = null; if(state instanceof BMSPlayer) { gauge = ((BMSPlayer) state).getGauge(); } else if(state instanceof AbstractResult) { gauge = ((AbstractResult) state).main.getPlayerResource().getGrooveGauge(); } if (gauge == null) { draw = false; return; } switch(animationType) { case ANIMATION_RANDOM: if (atime < time) { animation = (int) (Math.random() * (animationRange + 1)); atime = time + duration; } break; case ANIMATION_INCLEASE: if (atime < time) { animation = (animation + animationRange) % (animationRange + 1); atime = time + duration; } break; case ANIMATION_DECLEASE: if (atime < time) { animation = (animation + 1) % (animationRange + 1); atime = time + duration; } break; case ANIMATION_FLICKERING: animation = (int) (time % duration); break; } // TODO 9key固有実装の汎用化 if(!isCheckedSevenToNine) { if(state.main.getPlayerResource().getOriginalMode() == Mode.BEAT_7K && state.main.getPlayerResource().getBMSModel().getMode() == Mode.POPN_9K) { //7to9 ボーダーが丁度割り切れるゲージ粒数に変更 int setParts = parts; for(int type = 0; type < gauge.getGaugeTypeLength(); type++) { final GaugeElementProperty element = gauge.getGauge(type).getProperty(); for(int i = parts; i <= element.max; i++) { if(element.border % (element.max / i) == 0) { setParts = Math.max(setParts, i); break; } } } parts = setParts; } isCheckedSevenToNine = true; } value = gauge.getValue(); type = state instanceof AbstractResult ? ((AbstractResult) state).getGaugeType() : gauge.getType(); max = gauge.getGauge(type).getProperty().max; border = gauge.getGauge(type).getProperty().border; if(state instanceof AbstractResult) { PlayerResource resource = ((AbstractResult) state).main.getPlayerResource(); FloatArray gaugeTransition; if(state instanceof MusicResult) { gaugeTransition = resource.getGauge()[type]; } else { gaugeTransition = resource.getCourseGauge().get(resource.getCourseGauge().size - 1)[type]; } value = gaugeTransition.get(gaugeTransition.size - 1); if(time < starttime) { value = gauge.getGauge(type).getProperty().min; } else if(time >= starttime && time < endtime) { value = Math.min(value, Math.max(max * (time - starttime) / (endtime - starttime), gauge.getGauge(type).getProperty().min)); } } images = image.getImages(time, state); }
Example #7
Source File: MusicResult.java From beatoraja with GNU General Public License v3.0 | 4 votes |
public void render() { long time = main.getNowTime(); main.switchTimer(TIMER_RESULTGRAPH_BEGIN, true); main.switchTimer(TIMER_RESULTGRAPH_END, true); if (((MusicResultSkin) getSkin()).getRankTime() == 0) { main.switchTimer(TIMER_RESULT_UPDATESCORE, true); } if (time > getSkin().getInput()) { main.switchTimer(TIMER_STARTINPUT, true); } final PlayerResource resource = main.getPlayerResource(); if (main.isTimerOn(TIMER_FADEOUT)) { if (main.getNowTime(TIMER_FADEOUT) > getSkin().getFadeout()) { stop(SOUND_CLEAR); stop(SOUND_FAIL); stop(SOUND_CLOSE); main.getAudioProcessor().stop((Note) null); boolean[] keystate = main.getInputProcessor().getKeystate(); // System.out.println(Arrays.toString(keystate)); long[] keytime = main.getInputProcessor().getTime(); Arrays.fill(keytime, 0); if (resource.getCourseBMSModels() != null) { if (resource.getGauge()[resource.getGrooveGauge().getType()] .get(resource.getGauge()[resource.getGrooveGauge().getType()].size - 1) <= 0) { if (resource.getCourseScoreData() != null) { // 未達曲のノーツをPOORとして加算 final Array<FloatArray[]> coursegauge = resource.getCourseGauge(); final int cg = resource.getCourseBMSModels().length; for (int i = 0; i < cg; i++) { if (coursegauge.size <= i) { resource.getCourseScoreData().setMinbp(resource.getCourseScoreData().getMinbp() + resource.getCourseBMSModels()[i].getTotalNotes()); } } // 不合格リザルト main.changeState(MainStateType.COURSERESULT); } else { // コーススコアがない場合は選曲画面へ main.changeState(MainStateType.MUSICSELECT); } } else if (resource.nextCourse()) { main.changeState(MainStateType.PLAY); } else { // 合格リザルト main.changeState(MainStateType.COURSERESULT); } } else { main.getPlayerResource().getPlayerConfig().setGauge(main.getPlayerResource().getOrgGaugeOption()); ResultKeyProperty.ResultKey key = null; for (int i = 0; i < property.getAssignLength(); i++) { if (property.getAssign(i) == ResultKeyProperty.ResultKey.REPLAY_DIFFERENT && keystate[i]) { key = ResultKeyProperty.ResultKey.REPLAY_DIFFERENT; break; } if (property.getAssign(i) == ResultKeyProperty.ResultKey.REPLAY_SAME && keystate[i]) { key = ResultKeyProperty.ResultKey.REPLAY_SAME; break; } } if (resource.getPlayMode() == PlayMode.PLAY && key == ResultKeyProperty.ResultKey.REPLAY_DIFFERENT) { Logger.getGlobal().info("オプションを変更せずリプレイ"); // オプションを変更せず同じ譜面でリプレイ resource.getReplayData().pattern = null; resource.reloadBMSFile(); main.changeState(MainStateType.PLAY); } else if (resource.getPlayMode() == PlayMode.PLAY && key == ResultKeyProperty.ResultKey.REPLAY_SAME) { // 同じ譜面でリプレイ if(resource.isUpdateScore()) { Logger.getGlobal().info("同じ譜面でリプレイ"); } else { Logger.getGlobal().info("アシストモード時は同じ譜面でリプレイできません"); resource.getReplayData().pattern = null; } resource.reloadBMSFile(); main.changeState(MainStateType.PLAY); } else { main.changeState(MainStateType.MUSICSELECT); } } } } else { if (time > getSkin().getScene()) { main.switchTimer(TIMER_FADEOUT, true); if (getSound(SOUND_CLOSE) != null) { stop(SOUND_CLEAR); stop(SOUND_FAIL); play(SOUND_CLOSE); } } } }
Example #8
Source File: CourseResult.java From beatoraja with GNU General Public License v3.0 | 4 votes |
public void create() { final PlayerResource resource = main.getPlayerResource(); for(int i = 0;i < REPLAY_SIZE;i++) { saveReplay[i] = main.getPlayDataAccessor().existsReplayData(resource.getCourseBMSModels(), resource.getPlayerConfig().getLnmode(), i ,resource.getConstraint()) ? ReplayStatus.EXIST : ReplayStatus.NOT_EXIST ; } setSound(SOUND_CLEAR, "course_clear.wav", SoundType.SOUND,false); setSound(SOUND_FAIL, "course_fail.wav", SoundType.SOUND, false); setSound(SOUND_CLOSE, "course_close.wav", SoundType.SOUND, false); loadSkin(SkinType.COURSE_RESULT); for(int i = resource.getCourseGauge().size;i < resource.getCourseBMSModels().length;i++) { FloatArray[] list = new FloatArray[resource.getGrooveGauge().getGaugeTypeLength()]; for(int type = 0; type < list.length; type++) { list[type] = new FloatArray(); for(int l = 0;l < (resource.getCourseBMSModels()[i].getLastNoteTime() + 500) / 500;l++) { list[type].add(0f); } } resource.getCourseGauge().add(list); } property = ResultKeyProperty.get(resource.getBMSModel().getMode()); if(property == null) { property = ResultKeyProperty.BEAT_7K; } updateScoreDatabase(); // リプレイの自動保存 if(resource.getPlayMode() == PlayMode.PLAY){ for(int i=0;i<REPLAY_SIZE;i++){ if(MusicResult.ReplayAutoSaveConstraint.get(resource.getConfig().getAutoSaveReplay()[i]).isQualified(oldscore ,getNewScore())) { saveReplayData(i); } } } gaugeType = resource.getGrooveGauge().getType(); }