w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Minesweeper increasing count of adjacent mine grids
if (grid[r][c].isValidSquare(int rr, int cc) == true) Isn't valid code. Try if (grid[r][c].isValidSquare(rr, cc) == true). Also, checking is a boolean is true of false is normally done without using the true/false values. i.e. if (grid[r][c].isValidSquare(rr, cc)).

Categories : Java

How do check for keyboard input while continuing to update and draw game items
Allegro's al_get_keyboard_state does just that: It returns the current state of the keyboard at the time of the call.

Categories : C++

Writing a text based game, I'm confused as to how to check input on button press and then update
You need to use an EventListener so your program can detect when the button has been pressed and check for the text in the textArea. Check out this tutorial. Here is a simple generic example: button.addActionListener (new ActionListener () { public void actionPerformed(ActionEvent e) { message = textArea.getText(); //Do stuff } });

Categories : Java

2d array game that moves to adjacent spaces picking up coins
Well I think col must be less than (map.length-1) instead of (map.length-2) For {1},{1}, map.length == 2 so map.length-2 = 0, then col must be less than 0 to execute the if block. Btw, you have map.length comparison to both col and row, so you map will be a square in any case?

Categories : Java

Multiple Grids to achieve Nested Grids functionality
Subscribe to select (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.grid.Panel-event-select) event of the TB1 and then filter store associated TB2 with whatever filter criteria you need - this way second grid will be automatically filtered to the records you need to show.

Categories : Extjs

Simple memory game doesn't update its state. Bad game loop?
I would check your addEventListener method: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener I also recommend you look into using jQuery.

Categories : Javascript

How to check that certain datetime is in between the adjacent row dates?
You could put all the four checks into subqueries: SELECT (SELECT movement FROM user WHERE Date <= ? ORDER BY Date) = 'Static' AND (SELECT movement FROM user WHERE Date <= ? ORDER BY Date) = 'Static' AND (SELECT movement FROM user WHERE Date <= ? ORDER BY Date) = 'Static' AND (SELECT movement FROM user WHERE Date <= ? ORDER BY Date) = 'Static'; This will give you a single result record with a single boolean column.

Categories : Java

Check whether two points in time are in different adjacent days
I always use joda for date/time manipulation in Java. Using joda, your code is: if (Days.daysBetween(new DateTime(myFirstJavaUtilDateOrMiliseconds), new DateTime(mySecondJavaUtilDateOrMiliseconds)).getDays()) == 1) { // 1 day difference } else { // not so much } Of course, if you're using the JDK date classes and can't use Joda, accept a different answer.

Categories : Java

Google Play Game Services client setup and connecting
All set! Finally after some tries without result, here is the method (suitable for libgdx users). Answer to the First Question: There's no need at all to get requests or even use the AuthUtil class provided by google. Answer to the Second Question: Make sure to read some tutorials about GamesClient and its implementation. Step1: Get the BaseGameUtils library provided by Google, here. Step2: implement GameHelper.GameHelperListenner on your MainActivity, for example: public class MainActivity extends AndroidApplication implements GameHelper.GameHelperListener and declare a GameHelper that will do all the sign in work for you. (dont forget to call its constructor and setup method, see GameHelper class for more information). Step3: call beginUserInitiatedSignIn() (from the GameHelpe

Categories : Android

How to check for values adjacent to clicked table cell and replace that value if it is "empty" (HTML Javascript)
I would just loop from i = 1 to i < len - 1 and then do my magic on cells[i], cells[i-1], and cells[i+1]. Perhaps you just want to work with innerText instead to avoid issues with quoting of <>&'", etc.

Categories : Javascript

Rails links not connecting properly
Once you have declared the nested resources, don't declare those resources again. Deep nesting of resources is not recommended. You should think about doing shallow nesting, and you can read about this in the Rails Routing Guide. One way to avoid deep nesting (as recommended above) is to generate the collection actions scoped under the parent, so as to get a sense of the hierarchy, but to not nest the member actions. In other words, to only build routes with the minimal amount of information to uniquely identify the resource, like this: resources :posts do resources :comments, only: [:index, :new, :create] end resources :comments, only: [:show, :edit, :update, :destroy] This idea strikes a balance between descriptive routes and deep nesting.

Categories : Ruby On Rails

Best way to check a lot of check boxes in a checkboard game
It'll depend a lot on how you're representing your matrix... If I understood your problem, the easiest way is to simply make a loop, and for each row, count the number of checks checked. So: for each row: if col1 = is checked, check++ if col2 = is checked, check++ if col3 = is checked, check++ if check > 1 tell the user that there is an error. end for If you change your matrix to store a 0 value for unchecked and 1 for checked, you could test it like: for each row: if col1 + col2 + col3 > 1 tell the user that there is an error end for

Categories : C++

Check if a cell value is in between adjacent cell values in two columns
You can use an array formula to get the correct result. =IFERROR(INDIRECT("a"&MIN(IF((D2<$C$2:$C$25)*(D2>$B$2:$B$25),ROW($B$2:$B$25)))),"") In this formula column B = V1 from above, column C = V2 and column D = V3. The array formula entered in column E = Fx returns the first row where the criteria matches, then uses indirect to get the ID located in column A. The iferror inserts a blank when there is no match which causes the indirect function to error out.

Categories : Excel

Basic JavaScript Rock-Paper-Scissors game not working properly
You are using = instead of == in the while statement and same in all the if statements also = is the assignment operator, while == is the comparison operator var myChoice = ""; var compChoice = ""; var again; do { myChoice = prompt("Do you choose rock, paper or scissors?"); compChoice = Math.random(); if (compChoice < 0.33) { compChoice == "rock"; } else if(compChoice < 0.67) { compChoice = "paper"; } else { compChoice == "scissors"; } if (compChoice == myChoice) { alert("It's a tie!"); } else if (compChoice == "rock") { if(myChoice == "scissors") { alert("You lose!"); } else if (myChoice == "paper") { alert("You win!");

Categories : Javascript

Perl pipe object through a pipe dont work correctly
At the first, you can't write HTTP::Response into the stream directly. The error mean the string that written as "HTTP::Response..." haven't method decoded_content. You must write string got from decoded_content, and read as the string. use LWP::UserAgent; use IO::Handle; use Encode; pipe my $ua_reader, my $ua_writer; my $url = "http://some-sample-html-file"; my $ua = LWP::UserAgent->new; $ua->timeout(1); my $ua_process = fork(); if( $ua_process == 0 ) { close $ua_reader; print $ua_writer encode_utf8 $ua->get($url)->decoded_content; exit 0; } do { $ua_process = waitpid(-1, 1); } while ($ua_process != 0); close $ua_writer; my $response = $ua_reader->getline; close $ua_reader; print $response;

Categories : Perl

Named Pipe server can't get the pipe handle state
From the API docs: hNamedPipe [in] A handle to the named pipe for which information is wanted. The handle must have GENERIC_READ access for a read-only or read/write pipe, or it must have GENERIC_WRITE and FILE_READ_ATTRIBUTES access for a write-only pipe. If you have opened your pipe handle (pipe) with only PIPE_ACCESS_OUTBOUND, I don't think you satisfy this condition. Hence the ERROR_ACCESS_DENIED error.

Categories : C++

Better way to check game objects collisions
Divide your game world into cells, which contain a list of pointers to objects that reside within them. Make sure to update your cells when objects move between them and the size of the cell is larger than your biggest object. Only check collisions with objects in the same cell and adjacent cells. You can experiment with cell sizes and refine with more optimizations later on.

Categories : C++

To ignore Pipe in pipe delimited file
With GNU awk you would need to use FPAT to describe what a field is instead of using FS to describe what the field separator is. For example: $ cat file xx|yy|AAA|12 xx|"yy|xx"|AAA|12 $ awk '{$3=""}1' OFS='|' FPAT='([^|]+)|("[^"]+")' file xx|yy||12 xx|"yy|xx"||12 However you'd might be better of using a higher level language that has a CSV parsing module such as python.

Categories : Shell

Java game logic, check if object is placed in one of possible positions
You might want to start with the same list of "possible places" for all objects of the same type, then when an object is placed at [X,Y] -- remove that [X,Y] from the lists of remaining "unplaced" objects.

Categories : Java

Conway's Game of Life Update(Next Generation)
It looks like you are trying to modify the same grid you are looping through. As you loop through your grid, changes should be made based on the previous state of the grid. Try constructing a new grid instead of writing over the old one.

Categories : Java

how to update my label subviews based on how many player are left in the game
Not sure I understand what you need exactly, but you could set a flag for each player ie player1.isPlaying = YES; Loop through the current active players.

Categories : IOS

Insert function to insert record in SQL table working properly but Update Function to Update Record is not working properly
Check to make sure that rollno passed to the update function is correct. If the command is not throwing error, most likely it's executing correctly and ending up updating nothing because no record hits the supplied rollno. Put a break point at beginning of update function and check the supplied value of rollno. Also, roll no. in your insert statement is a subset of 's' whereas in update, its provided separately, you may need to check if that's OK.

Categories : C#

Water jug puzzle in SWI-Prolog
in Prolog, it make little sense to output the action 'description', because any sequence of actions that will fail will be undone, thus trying any available alternative. Then the first step I would take is a 'cosmetic one' : move away the description, that can be inferred from two adjacent steps of a solution (the list Z), and add a Solution argument to maneuver. Another important improvement: all your steps repeat the same - wrong - pattern: for instance + member(Z, (4,Y)), append(Z, [(4,Y)], A) make a 'subroutine' (and correct the mistake, that - I think - leads to the loop): update(State, Step, Updated) :- + member(Step, State), append(State, [Step], Updated).

Categories : Prolog

Webgl: Water effect in 2D
Use several textures, like bluish for water, black-and-white caustics for caustics and stone texture for floor. Then write fragment shader that would distort textures over time and simulate different effects you're up to. Hope this helps.

Categories : Javascript

How to check if I have properly installed Android SDK?
I just went through this process the other day! Here's the tutorial I used to do a "Hello World" Android app: http://developer.android.com/training/basics/firstapp/creating-project.html

Categories : Java

Best way to check if an instance was instantiated properly
You can set a public boolean property inside the class and in the specific constructor you can make it true. The default value of this property can be false. So if the object is obj1, you can check this boolean before calling the function. if(obj1.public_property) // do function call This is just a solution. There may be better solutions than this.

Categories : C#

Bounce Game in Tkinter. Gives Error saying "can't invoke "update" command: application has been destroyed"
The solution is to stop doing the while loop, and instead take advantage of tkinter's event loop. For example: def draw_frame(): '''Draws a new frame every N milliseconds''' ball.draw() paddle.draw() root.after(10, draw_frame) # draw the first frame once the GUI starts up after_idle(draw_frame) # start the event loop root.mainloop() You can adjust the speed of your program by changing the first argument to after.

Categories : Python

ZMQ high water mark deprecated on 3.x.x?
Have a look at: http://zeromq.org/docs:3-1-upgrade In zeromq 3.2 HWM has been split into send and receive high water mark: ZMQ_SNDHWM and ZMQ_RCVHWM. The functions you are looking for in jzmq are: long getRcvHWM() long getSndHWM() void setRcvHWM(long rcvHWM) void setSndHWM(long sndHWM)

Categories : Scala

Water 2D wave effect in JavaFX
In this tutorial you can find how to use custom GLSL/HLSL pixel shaders for JavaFX. And the code for a simple distortion procedural wave in screenSpace in HLSL form: uniform extern texture ScreenTexture; sampler ScreenS = sampler_state { Texture = <ScreenTexture>; }; float wave; // pi/.75 is a good default float distortion; // 1 is a good default float2 centerCoord; // 0.5,0.5 is the screen center float4 PixelShader(float2 texCoord: TEXCOORD0) : COLOR { float2 distance = abs(texCoord - centerCoord); float scalar = length(distance); // invert the scale so 1 is centerpoint scalar = abs(1 - scalar); // calculate how far to distort for this pixel float sinoffset = sin(wave / scalar); sinoffset = clamp(sinoffse

Categories : Java

Three.js Retrieve data from WebGLRenderTarget (water sim)
Ok, I figured out how to read the data using native webgl calls: // Render first scene into texture renderer.render( sceneRTT, cameraRTT, rtTexture, true ); // read render texture into buffer var gl = renderer.getContext(); gl.readPixels( 0, 0, simRes, simRes, gl.RGBA, gl.UNSIGNED_BYTE, buf1.image.data ); buf1.needsUpdate = true; The simulation now animates. However, it doesn't seem to be functioning properly (probably a dumb error I'm overlooking). It seems that the height values are never being damped and I'm not sure why. The data from buf1 is used in the fragment shader, which calculates the new height (red in RGBA), damps the value (multiplies by 0.99), then renders it to a texture. I then read this updated data from the texture back into buf1. Here's the latest fiddle: http://j

Categories : Three Js

How to update row in CursorAdapter properly
Just do this adjustments: final ImageView fav_img = (ImageView) v.findViewById(R.id.image); Boolean is_favourite = false; if (fav_img != null) { if (tmp.getIsFav() != 0) { fav_img.setImageResource(R.drawable.fav); } else fav_img.setImageResource(R.drawable.unfav); } fav_img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (is_favourite) // if your row is already favourite { is_favourite=false; fav_img.setImageResource(R.drawable.unfav); } else { is_favourite= true; fav_img.setImageResource(R.drawable.fav); } //Log.d("fav:", Integer

Categories : Android

cant get array to update properly
Try this: int main() { string textRad = ""; int histogram[ANTAL_BOKSTAVER]; getline(cin, textRad); berakna_histogram_abs(histogram, textRad); cout << histogram[0] << endl; cout << histogram[2]; return 0; } void berakna_histogram_abs(int histogram[], string textRad) { for(int i = 0; i < ANTAL_BOKSTAVER; i++) histogram[i] = 0; string alfabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for(int i = 0; i < textRad.length(); i++) { for(int j = 0; j < alfabet.length(); j++) if(char(toupper(textRad.at(i))) == alfabet.at(j)) histogram[j]++; } }

Categories : C++

check box not working properly at page load
This is because you have just wrote ONLY to uncheck the checkboxes in the pageload and not to disable the controls behind the checkbox; If thats needed, then your snippet in the pageload should be: if (!Page.IsPostBack) { ChckOrdType.Checked = false; ChkPlntPric.Checked = false; ChkExcluBro.Checked = false; ...... ..... ddlOrdType.Enabled = false; ddlPlntPric.Enabled = false; ddlExcluBroker.Enabled = false; ......... } or if (!Page.IsPostBack) { ChckOrdType.Checked = false; ChkPlntPric.Checked = false; ChkExcluBro.Checked = false; ...... ..... ChckOrdType_CheckChanged(sender,e); chkPlntPric_CheckChanged(sender,e); chkExcluBro_CheckChanged(sender,e); ... }

Categories : C#

How to PROPERLY check android permission dynamically
You can use this method: //for example, permission can be "android.permission.WRITE_EXTERNAL_STORAGE" public boolean hasPermission(String permission) { try { PackageInfo info = getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS); if (info.requestedPermissions != null) { for (String p : info.requestedPermissions) { if (p.equals(permission)) { return true; } } } } catch (Exception e) { e.printStackTrace(); } return false; }

Categories : Android

Trigger can't work properly when check condition
Is it really the INSERT statement that "doesn't work"? Or, is the problem that the INSERT statement is not being executed at all? What happens when the preceding SELECT query does not return a row? What value gets assigned to X? When X has that value, does a conditional test "foo != X" return TRUE, or does it return something else (like FALSE, or NULL)? Have you tried something like this? IF NEW.product_ID = X THEN UPDATE ... ELSE INSERT ... END IF; (I know it's bad practice to answer a question with a question; but it seemed apropros, since answering those will get you the answer to the question you really wanted to ask.)

Categories : Mysql

SQL - daily water consumption. Difference between days
since the consumption is never going to decrease (hour to next hour), can you not take MAX(consumption) - MIN(consumption) for each date? Update: You may have to do MIN(consumption_today) - MIN(consumption_yesterday) to include and account for all consumption that happened between last reading of yesterday and first reading of today.

Categories : SQL

Water ripple - The image cannot load on first time
A common error when this type of issue occurs, is that you are trying to draw the image before it loads. Try utilizing the img.onload function to wait until the image has loaded to do all of the drawing and then to start running the main loop.

Categories : Javascript

random perlinNoise in AS3 (for water ripple effect)
I think only applying the effect on random parts or partially each frame will look strange (I think you will see the "cheating"). Have you tried generating a displacement map image with half the resolution of the picture and then scale it up (with smoothing turned on) before using it as a displacement map? Maybe the lower resolution won't be that noticeable?

Categories : Actionscript

Water ripple effect on background of website
Have a look on these 2 demos, which i think you can get based to create yours. 29a.ch and mrdoob Hope this helps

Categories : Javascript

What's wrong with this code water boiling project
Your form is submitting to the current page. You should probably move your fill() to onsubmit for the form. Also, make sure that function returns false, or the form will still submit.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.